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.

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.

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