Unable to load image

rDrama Advent of Code Day 15: Box Edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

16
Jump in the discussion.

No email address required.

Solving was easy. Understanding the question in part 2 took me a long time though.

:marseyreading: :marseyhmm:

Jump in the discussion.

No email address required.

i have no idea wtf part 2 even is I'm gonna step away for a min lol

Jump in the discussion.

No email address required.

I think understanding the problem was the problem, but he made it too easy because the calculations were clear and everything you needed was in the last two paragraphs and worked examples.

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17026194252225971.webp

much easier today than the last few puzzles :marseybeandrool:

Jump in the discussion.

No email address required.

Python dicts happen to maintain the order of insertion. So box.pop(label, None) and box[label] = f are enough.

Then:

    for i, box in enumerate(boxes):
        for j, f in enumerate(box.values()):
            res += (i + 1 ) * (j + 1 ) * int(f)
Jump in the discussion.

No email address required.

for versions >=3.7 (and sometimes 3.6)

Jump in the discussion.

No email address required.

huh, never got the memo

Jump in the discussion.

No email address required.

This is just leetcode but with shitty prompts. I'm to busy gooning to do this crud

Jump in the discussion.

No email address required.

Thanks babe was in a meeting

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17026561584173608.webp

:#marseysquint:

Tomorrow you're going down babe

Jump in the discussion.

No email address required.

I have my grad school reunion today so I will not get around to it until tomorrow. Feel free to take my place

Jump in the discussion.

No email address required.

You've sapped all the joy out of this rivalry.

Jump in the discussion.

No email address required.

I guess today's was the annual "follow some rules as quickly as you can" problem. Pretty easy, no edge cases to consider, you just have to not get scared by Eric's words. Following the numbers worked fine...

Jump in the discussion.

No email address required.

I have a feeling we'll be seeing the lens boxes again in a week or so.

Jump in the discussion.

No email address required.

Why?

Jump in the discussion.

No email address required.

Unusually easy problems are often used to introduce concepts which will be needed in later days.

Jump in the discussion.

No email address required.

I hate that.

Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17026197108105917.webp

Nice to finish in less than an hour for once.

Jump in the discussion.

No email address required.

Who else tried to be a smartass with the last value before giving up and doing it the way Eric intended?

r←⊃⊃⎕NGET'15.in'1
b←{{256|17×⍵+⍺}/⌽0,⎕UCS ⍵}
⎕←+/b¨','(≠⊆⊢)r

i←{⍵,b⊃⍵}¨{3↑⍵⊆⍨1++\~⍵∊⎕C⎕A}¨','(≠⊆⊢)r
j←{(4⊃⍵)(⊃⍵)(2⊃⍵)(5⊃⍵)}¨i,¨{10|¯1+⎕D⍳⊃3⊃⍵}¨i
k←((1+⊃¨)⊆⊢)j⌷⍨⊂⍋⊃¨j
c←{
    s←⍬
    d←{0⊣s⊢←s/⍨⍵∘≢¨⊃¨s}
    f←{i←⍸(⊂⊃⍵)⍷⊃¨s ⋄ 0⊣(2⊃i⊃s)⊢←2⊃⍵}
    a←{(⊂⊃⍵)∊⊃¨s:f ⍵ ⋄ 0⊣s⊢←s,⊂⍵}
    _←{(3⊃⍵)='-':d 2⊃⍵ ⋄ a (⊂2 4)⌷⍵}¨⍵
    0≡≢s:0 ⋄ +/(1+⊃⊃⍵)×(⍳≢s)×2⊃¨s
}
⎕←+/c¨k
Jump in the discussion.

No email address required.

Being a smartass how? I can't read your alien language.

Jump in the discussion.

No email address required.

For each box, per label, the last op gave the focus and [index of first = op after last - op] gave the orders. So you didn't need to run every instruction. But the "shortcut" turned out to be annoying enough that the full simulation was easier.

Case in point, here's the '''cheese''':

c2←{
    l←2⊃¨⍵ ⋄ q←'='=3⊃¨⍵ ⋄ n←~q
    qi←(⍸∊)¨↓{q∧⍵}⍤1⊢x←⍉l(∘.≡)∪l
    m←∊0≠d←qi{1↑⍸⍵<⍺}¨∊{¯1↑⍸∊⍵}⍤1⊢{n∧⍵}⍤1⊢x
    0≡+/m:0
    v←(⊂⍋∊(m/d)⌷¨m/qi)⌷(⊂∊¯1∘↑¨m/qi)⌷⍵
    +/(4⊃¨v)×(⍳≢v)×1+⊃⊃⍵
}
Jump in the discussion.

No email address required.

Really? That was it?

https://i.rdrama.net/images/1702660855620077.webp

Jump in the discussion.

No email address required.

Probably one of the easiest so far, I spent more time trying to understand part 2 than I did coding.

https://i.rdrama.net/images/1702619199679669.webp

Jump in the discussion.

No email address required.

Oh look it a write your own hashmap problem

https://i.rdrama.net/images/17026793598835533.webp

Jump in the discussion.

No email address required.

I give up :marseysulk: part B is le too hard

Jump in the discussion.

No email address required.

Hello Dahncer_the_reindeer, or should I say r*pedeer? 8 letters, fitting huh. If this life were perfect you'd have known nothing but milk and cookies since you left your birthers c*nt. However, it's not- that's where I come in.

You have no say anymore, no freedom, no volition- I am Santa. You now worship my Christmas tree. You can call me Nicholas. A saint? No, but I come with more conviction.

Dahncer_the_reindeer you are my r*pe sleigh-ve now. And that's your greatest achievement- all you've ever amounted to, tugging and pulling my sleigh as we break the space time continuum together you complete fricking slut. I'll find you.

Snapshots:

https://carbon.vercel.app:

https://adventofcode.com/2023:

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.