AoC day 2 solution 

⎕IO←0
find_in←{
⍺←0 0
t←⍺
t[1]+←1
⍺[1]>99:⍺{t[0]+←1 ⋄ t[1]←¯1 ⋄ t find_in ⍵}⍵
in←⍵
in[0;1 2]←t[0 1]
19690720=0⌷intcode in:t
t∇in
}
intcode←{
⍺←0
one←{r←,⍵ ⋄ r[⍵[⍺;3]]←r[⍵[⍺;1]]+r[⍵[⍺;2]] ⋄ (⍺+1)intcode(⍴⍵)⍴r}
two←{r←,⍵ ⋄ r[(⍵[⍺;3])]←r[⍵[⍺;1]]×r[⍵[⍺;2]] ⋄ (⍺+1)intcode(⍴⍵)⍴r}
1=0⌷⍵[⍺;]:⍺ one ⍵
2=0⌷⍵[⍺;]:⍺ two ⍵
99=0⌷⍵[⍺;]:,⍵
}
parse←{{((⌈4÷⍨⍴⍵),4)⍴⍵}⍎¨','(≠⊆⊢)⍵}
in_1←in←parse ⊃⊃⎕nget '02.input' 1
in_1[0;1 2]←12 2
pt1←0⌷intcode in_1
pt2←find_in in

Follow

re: AoC day 2 solution 

Not supper happy with how verbose this turned out to be – it's only day 2, and I already had to strip out the error handling code to fit in a toot.

Maybe I'll be able to be a bit more concise tomorrow…

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.