Skip to content

Instantly share code, notes, and snippets.

@codesections

codesections/05.dyalog

Last active Dec 6, 2019
Embed
What would you like to do?
Advent of Code day 5
⎕IO0
intcode{
0 i s instr'0'(,{4<}) opcode¯2instr p_modes¨3instr
p{modep_modes[-1]
mode=0:s[i+]
mode=1:i+
'ERR: Unknown parameter mode',mode}
is:'ERR: no HALT opcode'
1=opcode:{s[p 3]s[p 1]+s[p 2] (i+4) intcode s}
2=opcode:{s[p 3]s[p 1]×s[p 2] (i+4) intcode s}
3=opcode:{' IN: ' s[p 1]5 (i+2) intcode s}
4=opcode:{'OUT:',s[p 1] (i+2) intcode s}
5=opcode:{0s[p 1]: s[p 2] intcode s
(i+3) intcode s}
6=opcode:{0=s[p 1]: s[p 2] intcode s
(i+3) intcode s}
7=opcode:{s[p 1]<s[p 2]:{s[p 3]1 (i+4) intcode s}
{s[p 3]0 (i+4) intcode s} }
8=opcode:{s[p 1]=s[p 2]:{s[p 3]1 (i+4) intcode s}
{s[p 3]0 (i+4) intcode s} }
99=opcode:''
'ERR: Unknown opcode',opcode
}
in¨','() ⊃⊃⎕nget '05.input' 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.