summaryrefslogtreecommitdiffstats
path: root/2021/06
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-11-06 09:58:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-11-06 09:58:38 -0800
commit4fd1aae518076adc8b97735225c678d6a362328d (patch)
tree97d61b659fc3cac628d0cdee71128a0baee2cb73 /2021/06
downloadadvent-4fd1aae518076adc8b97735225c678d6a362328d.tar.gz
advent-4fd1aae518076adc8b97735225c678d6a362328d.tar.bz2
advent-4fd1aae518076adc8b97735225c678d6a362328d.zip
Kazinator's Advent of Code stuff.
Diffstat (limited to '2021/06')
-rw-r--r--2021/06/input1
-rw-r--r--2021/06/sim.tl31
-rw-r--r--2021/06/testinput1
3 files changed, 33 insertions, 0 deletions
diff --git a/2021/06/input b/2021/06/input
new file mode 100644
index 0000000..66ede3c
--- /dev/null
+++ b/2021/06/input
@@ -0,0 +1 @@
+3,5,2,5,4,3,2,2,3,5,2,3,2,2,2,2,3,5,3,5,5,2,2,3,4,2,3,5,5,3,3,5,2,4,5,4,3,5,3,2,5,4,1,1,1,5,1,4,1,4,3,5,2,3,2,2,2,5,2,1,2,2,2,2,3,4,5,2,5,4,1,3,1,5,5,5,3,5,3,1,5,4,2,5,3,3,5,5,5,3,2,2,1,1,3,2,1,2,2,4,3,4,1,3,4,1,2,2,4,1,3,1,4,3,3,1,2,3,1,3,4,1,1,2,5,1,2,1,2,4,1,3,2,1,1,2,4,3,5,1,3,2,1,3,2,3,4,5,5,4,1,3,4,1,2,3,5,2,3,5,2,1,1,5,5,4,4,4,5,3,3,2,5,4,4,1,5,1,5,5,5,2,2,1,2,4,5,1,2,1,4,5,4,2,4,3,2,5,2,2,1,4,3,5,4,2,1,1,5,1,4,5,1,2,5,5,1,4,1,1,4,5,2,5,3,1,4,5,2,1,3,1,3,3,5,5,1,4,1,3,2,2,3,5,4,3,2,5,1,1,1,2,2,5,3,4,2,1,3,2,5,3,2,2,3,5,2,1,4,5,4,4,5,5,3,3,5,4,5,5,4,3,5,3,5,3,1,3,2,2,1,4,4,5,2,2,4,2,1,4
diff --git a/2021/06/sim.tl b/2021/06/sim.tl
new file mode 100644
index 0000000..69d9ac2
--- /dev/null
+++ b/2021/06/sim.tl
@@ -0,0 +1,31 @@
+(defun read-fish (name)
+ (flow
+ (file-get-string name)
+ (tok #/\d+/)
+ (mapcar toint)))
+
+(defun sim-naive (input n)
+ (while (plusp (pdec n))
+ (upd input (mappend [iff zerop (ret '(6 8)) [chain pred list]])))
+ (len input))
+
+(defun sim (input n)
+ (let ((phase (vector 9 0)))
+ (each ((i input))
+ (inc [phase i]))
+ (while (plusp (pdec n))
+ (rotate [phase 0] [phase 1] [phase 2]
+ [phase 3] [phase 4] [phase 5]
+ [phase 6] [phase 7] [phase 8])
+ (inc [phase 6] [phase 8]))
+ (sum phase)))
+
+(defun sim2 (input n)
+ (let ((phase (vector 9 0)))
+ (each ((i input))
+ (inc [phase i]))
+ (while (plusp (pdec n))
+ (pset [phase 8] [phase 0]
+ [phase 0..8] [phase 1..9])
+ (inc [phase 6] [phase 8]))
+ (sum phase)))
diff --git a/2021/06/testinput b/2021/06/testinput
new file mode 100644
index 0000000..55129f1
--- /dev/null
+++ b/2021/06/testinput
@@ -0,0 +1 @@
+3,4,3,1,2