-
Notifications
You must be signed in to change notification settings - Fork 1
/
day2-1.prdc
39 lines (38 loc) · 1.72 KB
/
day2-1.prdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
iIgHr2:12HudHL,4/εHt(3%"Q+*"=S{)\Ht~}uPdHu};sHq .. 48 bytes
{
i .. read full input
Ig .. read int groups thereof
Hr .. put this array into H, the default hoard
2: .. put 2 on the stack and duplicate it
12 .. put 1 and 12 on the stack (yes that's U+0001 START OF HEADING sorry)
.. I should make this α on the codepage or something. Anyway, paradoc's
.. push-constants-onto-stack story still needs improvement.
Hud .. update H (Hu) with two disjoint argument groups on the stack (_d)
HL, .. take the length of H and convert it to indices
4/ .. divide into chunks of 4
ε .. for each chunk:
Ht .. "translate" this through hoard to get four relevant contents of memory
.. (honestly i'm so impressed by my past self's prescience to make this
.. a hoard trailer)
( .. uncons to get the opcode
3% .. mod 3: 1 -> 1, 2 -> 2, 99 -> 0
"Q+*"= .. find a char that says what operation we want to do; this will be
.. evaluated as Paradoc (Q is break out of the loop)
.. (a two-byte "index mod length of the list" built-in would save a
.. char here and seems like a good idea)
S .. convert to string
.. stack: addr1 addr2 addr3 opstr
{ .. ignoring opstr:
) .. uncons: [addr1 addr2] addr3
\ .. swap, need to lookup in memory one more time
Ht .. translate through hoard: stack: addr3 [val1 val2]
~ .. expand onto stack: addr3 val1 val2
}u .. do the preceding block under the top element of the stack
.. stack: addr3 val1 val2 opstr
Pd .. evaluate the string as paradoc
.. stack: addr3 resultvalue
Hu .. update hoard at that position to that value
}
;s .. pop everything off the stack
Hq .. get the first element of the hoard
};