aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-12-23 18:25:53 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2016-12-23 18:25:53 +0100
commitf75770d98907dbfb1c52a9b05c16ed1c7e40dc06 (patch)
tree0929a3877b6e2a3f0ced644e3798c5b39cbc1e0a
parent334f4717ec3d24ac94d38d81e1204ee0ead0c32f (diff)
downloadadventofcode2016-f75770d98907dbfb1c52a9b05c16ed1c7e40dc06.tar.gz
adventofcode2016-f75770d98907dbfb1c52a9b05c16ed1c7e40dc06.tar.xz
adventofcode2016-f75770d98907dbfb1c52a9b05c16ed1c7e40dc06.zip
day23
-rw-r--r--day2326
-rw-r--r--day23.k19
-rw-r--r--day23.opt26
3 files changed, 71 insertions, 0 deletions
diff --git a/day23 b/day23
new file mode 100644
index 0000000..6d08532
--- /dev/null
+++ b/day23
@@ -0,0 +1,26 @@
+cpy a b
+dec b
+cpy a d
+cpy 0 a
+cpy b c
+inc a
+dec c
+jnz c -2
+dec d
+jnz d -5
+dec b
+cpy b c
+cpy c d
+dec d
+inc c
+jnz d -2
+tgl c
+cpy -16 c
+jnz 1 c
+cpy 75 c
+jnz 78 d
+inc a
+inc d
+jnz d -2
+inc c
+jnz c -5
diff --git a/day23.k b/day23.k
new file mode 100644
index 0000000..1543c43
--- /dev/null
+++ b/day23.k
@@ -0,0 +1,19 @@
+p:" "\'0:"day23"
+v:{(r,"i"$,x)"abcd"?*x}
+
+tgl:{s:~[**p[x]]
+ `0:"TGL ",($x),"\n"
+ $[s"i";p::.[p;x,0;"dec"]
+ s"d";p::.[p;x,0;"inc"]
+ s"t";p::.[p;x,0;"inc"]
+ s"j";p::.[p;x,0;"cpy"]
+ s"c";p::.[p;x,0;"jnz"]
+ ]}
+
+e:{t:"abcd"?**|c:p[i]; i+:1; s:~[**c;]
+ $[s"m";r[0]:r[3]*r[1]; s"t";tgl[i+(-1)+v@*|c]; s"c";$[t<#r;r[t]:v@c@1;]; s"i";r[t]+:1; s"d";r[t]-:1; s"j";i+:(-1+v@*|c)*~0=v@c@1]; r}
+
+r:7 0 0 0;i:0;*{i<#p}e/1 / 10890
+
+p:" "\'0:"day23.opt" / uses mul instruction for a=b*d (insn 4..9)
+r:12 0 0 0;i:0;*{i<#p}e/1 / 479007450
diff --git a/day23.opt b/day23.opt
new file mode 100644
index 0000000..9c3caad
--- /dev/null
+++ b/day23.opt
@@ -0,0 +1,26 @@
+cpy a b
+dec b
+cpy a d
+cpy 0 a
+mul 0 0
+cpy 0 d
+cpy 0 c
+cpy 0 c
+cpy 0 c
+cpy 0 c
+dec b
+cpy b c
+cpy c d
+dec d
+inc c
+jnz d -2
+tgl c
+cpy -16 c
+jnz 1 c
+cpy 75 c
+jnz 78 d
+inc a
+inc d
+jnz d -2
+inc c
+jnz c -5