about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-12-27 12:12:38 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-12-27 12:12:38 +0100
commit03f9fa40853804d1d60381d189bcf8e5bb7ad07c (patch)
treebd4a6cce1e12e8656f85bac33c8c1e8827f7b4e3
parent3aae077b4fd439d5f5ef4778b7efc37e1986ccca (diff)
downloadadventofcode2022-03f9fa40853804d1d60381d189bcf8e5bb7ad07c.tar.gz
adventofcode2022-03f9fa40853804d1d60381d189bcf8e5bb7ad07c.tar.xz
adventofcode2022-03f9fa40853804d1d60381d189bcf8e5bb7ad07c.zip
day25 HEAD master
-rw-r--r--day25116
-rw-r--r--day25.k1
-rw-r--r--day25.rkt32
3 files changed, 149 insertions, 0 deletions
diff --git a/day25 b/day25
new file mode 100644
index 0000000..4837f2e
--- /dev/null
+++ b/day25
@@ -0,0 +1,116 @@
+1-12212=-=--=0221
+1----2-1
+1=2==-1-1=1-02---
+220--0=2-01-
+2=02-101-2-0221
+10=-21-
+1-02-0-10=0002
+20
+1==0-
+22-1201-011=
+1-
+22=21
+121-=02=1--222
+2=-=2
+1--1=-2-002-=-21
+1=-=1=1-==0=-
+1-==01000-1-121
+1=0=1==00=1-
+2110-1-21201002-0=1
+1--=11
+2=0-0-2=20020=1=1
+1-0=2-=12020111-1222
+101-=0--=1=00101
+2-=022-0-22=12=-0
+2=-1201-20==-2=20
+1-=21001
+1==2210220
+1=-21--1-
+1--==0212-10021-=1
+10-
+102011-0=2=
+22-100=---0-0
+1-0222--0-220--
+10211
+1-2--=10=-1-
+1-20-111
+1-1202=1=021
+2==0==0-0=2
+2=210=01--=011-
+21-
+1=02-210-0
+11
+1-0-21===0-=1-=2-
+10=22012=2-0-12-
+112
+21-1-22
+1=0010021=01
+2-0=120
+1=0-0-2-0-=
+212=20--
+1-=1--21-=
+1--
+2-12---=1202-1
+2=1
+1-0-11=021
+2-0-120-
+1-=10102-0-11201121
+1021---
+1=02=0012=-00=211
+10-1=2-0=-1-=
+11-1=0==1
+1=-1--12222
+1=00-0
+1--211
+1=10-=2=22--==-
+1=0=12--212=--=-1
+10200
+100=22=020210=12=-
+2-1=0=221
+1-02-0=
+2-1-20
+220=20
+22=202
+1==11=-11
+21=21=10=2=2=
+10100=-1===--2--=-
+1=-012=1
+210==0=-0-2120
+1002220--00=22
+1-2
+202-=1221-=----1
+202-0201122-2
+10010-02=02-1
+11=02-0--2=-10
+1==2-22--=1=-12=--
+12000
+1===1--=2-2=2----==
+10-12=
+1=1--=2==12
+1-2=0=12=0
+1=-1
+1=2-=0=020=-00=
+1-0-211-
+12-=1=01=0=22-2==2
+2=2=0-02-2
+212022
+101=11=
+1=00-2==0201==1
+2=-011=212221=212
+2-2
+1=-20-=--101
+1-212=12=0-0==1-
+2--2-1-0-11-2
+20-
+11-----0-
+102--=1011=01
+1--11--
+1-2=1=1==20111
+21200-===20
+1-0=12-0=
+2---
+20-2=
+1=-
+221-==
+1-01212==01-1220
+1-01202=10--010001
diff --git a/day25.k b/day25.k
new file mode 100644
index 0000000..91c575d
--- /dev/null
+++ b/day25.k
@@ -0,0 +1 @@
+1_c@|5!2+{_(x+2)%5}\+/(5/-2+(c:"=-012")?)'0:"day25"
diff --git a/day25.rkt b/day25.rkt
new file mode 100644
index 0000000..d3bc34a
--- /dev/null
+++ b/day25.rkt
@@ -0,0 +1,32 @@
+#lang racket
+(require srfi/1)
+
+(define data (for/list ([line (file->lines "day25")])
+               (for/list ([c line])
+                 (match c
+                   [#\2 2]
+                   [#\1 1]
+                   [#\0 0]
+                   [#\- -1]
+                   [#\= -2]))))
+
+(define (base5 ns)
+  (foldl (lambda (x a) (+ (* 5 a) x)) 0 ns))
+
+(define (unbase5 n)
+  (list->string (reverse (unfold zero?
+                                 (lambda (n) (match (modulo (+ n 2) 5)
+                                               [0 #\=]
+                                               [1 #\-]
+                                               [2 #\0]
+                                               [3 #\1]
+                                               [4 #\2]))
+                                 (lambda (n) (quotient (+ n 2) 5))
+                                 n))))
+
+; (map base5 data)
+
+(unbase5 (for/sum ([n data])
+           (base5 n)))
+
+;; "2-0-020-1==1021=--01"