summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-11-07 19:46:26 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-11-07 19:46:26 -0800
commitc6fffc483cfdbb1102f67b39557840238d026dff (patch)
tree83d8cd79b7448e0a79b23e7a605c4336a6e06575
parent4fd1aae518076adc8b97735225c678d6a362328d (diff)
downloadadvent-master.tar.gz
advent-master.tar.bz2
advent-master.zip
Add missing 2021/{13..16}.HEADmaster
-rw-r--r--2021/13/code.tl59
-rw-r--r--2021/13/input812
-rw-r--r--2021/13/testinput21
-rw-r--r--2021/14/code.tl48
-rw-r--r--2021/14/codes.tl42
-rw-r--r--2021/14/input102
-rw-r--r--2021/14/testinput18
-rw-r--r--2021/15/case010
-rw-r--r--2021/15/code-orig.tl86
-rw-r--r--2021/15/code.tl87
-rw-r--r--2021/15/graph30
-rw-r--r--2021/15/input100
-rw-r--r--2021/15/rubbish.tl99
-rw-r--r--2021/15/small05
-rw-r--r--2021/15/small15
-rw-r--r--2021/15/small29
-rw-r--r--2021/15/small39
-rw-r--r--2021/15/testinput10
-rw-r--r--2021/15/testinput250
-rw-r--r--2021/16/code.tl101
-rw-r--r--2021/16/input1
21 files changed, 1704 insertions, 0 deletions
diff --git a/2021/13/code.tl b/2021/13/code.tl
new file mode 100644
index 0000000..f222e27
--- /dev/null
+++ b/2021/13/code.tl
@@ -0,0 +1,59 @@
+(defstruct board ()
+ (w 0)
+ (h 0)
+ (a (hash))
+
+ (:method print (bo stream pretty-p)
+ (put-line `board @{bo.w}x@{bo.h}:`)
+ (each ((y 0..bo.h))
+ (each ((x 0..bo.w))
+ (put-char (if [bo x y] #\# #\space) stream))
+ (put-line)))
+
+ (:method lambda (bo x y)
+ [(or [bo.a y] nil) x])
+
+ (:method lambda-set (bo x y nv)
+ (let ((row (or [bo.a y]
+ (set [bo.a y] (hash)))))
+ (set [row x] nv)
+ (upd bo.h (max (succ y)))
+ (upd bo.w (max (succ x)))))
+
+ (:method fold-y (bo yline)
+ (let ((a bo.a))
+ (del [a yline])
+ (set bo.h yline)
+ (dohash (y row a bo)
+ (when (> y yline)
+ (let ((ry (- (* 2 yline) y)))
+ (if [a ry]
+ (set [a ry]
+ [hash-uni [a ry] [a y] or])
+ (set [a ry] row)))
+ (del [a y])))))
+
+ (:method fold-x (bo xline)
+ (let ((a bo.a))
+ (dohash (y row a bo)
+ (each ((x (succ xline)..bo.w))
+ (when [row x]
+ (set [row (- (* 2 xline) x)] t)
+ (del [row x])))))
+ (set bo.w xline))
+
+ (:method count (bo)
+ (let ((count 0))
+ (dohash (y row bo.a count)
+ (dohash (x v row)
+ (if v (inc count)))))))
+
+(defun solve-two (: (name "input"))
+ (let ((bo (new board)))
+ (each ((line (file-get-lines name)))
+ (match-case line
+ (`@x,@y` (set [bo (toint x) (toint y)] t))
+ (`fold along x=@x` bo.(fold-x (toint x)))
+ (`fold along y=@y` bo.(fold-y (toint y)))))
+ (print bo)
+ nil))
diff --git a/2021/13/input b/2021/13/input
new file mode 100644
index 0000000..556b07a
--- /dev/null
+++ b/2021/13/input
@@ -0,0 +1,812 @@
+726,774
+246,695
+579,249
+691,724
+246,820
+738,887
+1088,75
+264,887
+704,775
+907,625
+676,117
+507,658
+1009,24
+547,735
+157,126
+599,113
+445,226
+363,691
+918,794
+927,113
+999,400
+443,305
+654,729
+408,767
+1066,863
+1148,473
+321,35
+1093,803
+1044,718
+202,889
+262,164
+378,541
+619,662
+1034,849
+432,595
+1145,656
+1295,668
+1125,705
+1161,529
+759,619
+1170,147
+688,742
+328,729
+718,439
+935,701
+246,647
+594,110
+845,495
+160,189
+1225,315
+580,486
+469,481
+440,401
+584,774
+897,719
+1007,516
+547,159
+112,117
+982,645
+62,439
+192,441
+631,211
+654,16
+113,698
+378,865
+373,19
+441,777
+390,7
+1263,312
+1121,610
+509,582
+893,352
+44,131
+1092,19
+592,719
+918,100
+326,820
+62,719
+520,889
+718,103
+571,579
+1165,267
+1208,334
+525,415
+268,588
+769,464
+596,716
+734,436
+1283,747
+35,457
+982,94
+1235,849
+932,752
+1265,243
+262,752
+99,704
+547,732
+1096,829
+791,329
+1222,320
+199,568
+671,494
+1079,93
+569,315
+129,415
+868,878
+788,803
+1175,889
+965,676
+904,660
+552,560
+619,484
+507,236
+566,768
+1215,30
+45,410
+885,441
+478,336
+945,397
+596,306
+1145,686
+189,495
+1153,126
+79,444
+719,403
+903,91
+27,105
+441,329
+768,565
+671,400
+507,205
+224,390
+867,753
+425,441
+1123,67
+833,14
+793,278
+1237,724
+238,808
+1099,32
+411,243
+1,574
+726,120
+862,441
+212,94
+80,199
+1047,312
+164,389
+440,773
+185,189
+412,114
+537,792
+403,697
+1208,768
+408,527
+1135,831
+746,826
+1064,110
+15,226
+102,574
+1001,442
+769,16
+1236,408
+440,121
+1309,131
+771,473
+1064,527
+189,284
+427,704
+276,865
+986,593
+1009,870
+745,276
+965,291
+1190,5
+1084,768
+313,750
+976,544
+1222,658
+223,619
+718,791
+976,574
+705,822
+785,863
+388,390
+1235,716
+579,645
+90,378
+497,849
+1308,145
+658,301
+648,94
+1150,189
+231,129
+408,639
+390,119
+132,556
+639,220
+885,453
+413,651
+639,68
+177,544
+552,782
+239,130
+867,645
+187,67
+1163,494
+1227,19
+249,658
+132,270
+740,82
+73,206
+1166,525
+262,506
+1092,875
+923,509
+967,400
+813,849
+734,364
+604,541
+566,758
+90,852
+190,831
+1047,65
+313,144
+542,157
+720,304
+129,863
+1280,149
+448,441
+947,484
+1048,506
+408,863
+657,803
+480,834
+201,369
+489,208
+1275,36
+1064,784
+781,845
+1071,152
+1251,61
+455,500
+564,68
+758,798
+922,390
+443,421
+505,792
+60,784
+1059,645
+741,315
+89,164
+142,637
+348,705
+763,735
+165,686
+711,781
+1220,852
+455,120
+1205,859
+1208,413
+1098,240
+33,505
+821,208
+35,289
+1251,833
+1131,226
+745,730
+75,625
+905,75
+738,7
+1223,316
+923,395
+7,884
+1153,299
+552,96
+1047,134
+642,266
+537,698
+1211,190
+959,235
+1235,625
+711,614
+510,798
+73,306
+47,582
+657,875
+468,75
+638,346
+144,525
+612,665
+917,57
+1235,402
+211,249
+831,63
+1197,250
+493,686
+887,801
+85,315
+263,65
+924,306
+140,595
+997,141
+657,173
+579,850
+489,686
+448,5
+572,7
+1248,103
+445,674
+711,113
+1232,884
+1121,278
+845,732
+786,630
+114,712
+691,662
+140,147
+1088,299
+408,191
+897,691
+92,662
+904,754
+1309,621
+102,768
+7,10
+33,429
+903,803
+2,749
+1083,704
+157,819
+325,91
+830,386
+763,284
+175,63
+902,199
+887,129
+1285,297
+1287,683
+590,304
+714,716
+6,686
+1136,834
+452,889
+653,315
+135,145
+683,329
+251,473
+1110,455
+959,516
+1091,838
+407,220
+654,800
+549,239
+765,355
+113,250
+771,93
+194,270
+864,803
+517,417
+345,291
+253,724
+365,145
+522,624
+692,495
+830,834
+1021,301
+825,595
+145,890
+1125,481
+48,119
+82,7
+965,666
+540,630
+542,121
+731,290
+85,763
+957,297
+1277,617
+1089,239
+619,612
+62,175
+427,190
+401,724
+1133,798
+475,882
+1062,140
+246,784
+1001,515
+244,31
+759,171
+1246,282
+249,236
+919,816
+907,25
+755,403
+557,725
+15,332
+840,861
+1031,760
+965,218
+813,45
+440,829
+885,457
+45,243
+351,435
+191,565
+984,820
+715,275
+689,641
+289,845
+575,892
+605,822
+1136,508
+137,278
+870,513
+59,621
+79,539
+89,276
+1,621
+753,725
+1119,301
+1,763
+1159,539
+1059,25
+267,843
+1072,236
+1203,607
+425,453
+62,551
+788,624
+576,884
+326,430
+345,452
+539,473
+1195,337
+981,432
+23,683
+455,394
+1098,654
+1118,441
+1277,429
+567,625
+773,698
+23,459
+441,464
+870,488
+567,269
+517,399
+935,302
+436,875
+309,442
+900,191
+1277,277
+1310,165
+383,781
+149,792
+492,578
+88,658
+736,500
+103,275
+731,44
+720,794
+1278,600
+981,462
+1020,623
+329,462
+333,483
+977,880
+1181,863
+509,890
+846,831
+246,527
+570,754
+841,481
+78,884
+1231,355
+618,47
+413,719
+850,786
+174,386
+364,175
+1193,196
+162,421
+221,239
+373,875
+718,7
+1231,539
+1218,662
+333,868
+885,9
+30,149
+1299,511
+227,190
+1197,698
+1150,705
+657,238
+783,717
+1159,383
+212,688
+241,719
+618,495
+1232,458
+985,432
+27,75
+918,506
+328,800
+145,582
+387,395
+90,516
+1019,773
+334,574
+1285,149
+716,558
+413,236
+353,477
+607,193
+845,844
+874,875
+1099,648
+264,63
+99,491
+263,312
+303,67
+463,565
+433,239
+902,527
+132,355
+1300,550
+606,119
+291,849
+25,86
+301,865
+1046,831
+805,102
+408,598
+1101,693
+1215,864
+947,691
+64,730
+1237,170
+970,628
+1136,60
+947,730
+334,544
+1149,686
+1009,198
+691,282
+691,457
+378,142
+599,614
+648,320
+507,400
+1178,803
+478,558
+267,51
+279,701
+965,452
+691,232
+401,170
+219,838
+1292,413
+296,373
+246,127
+446,91
+894,86
+115,480
+1287,155
+433,655
+263,134
+87,630
+965,403
+107,623
+189,610
+330,749
+1121,271
+965,603
+135,749
+1059,473
+328,165
+27,147
+443,134
+1210,320
+1211,470
+415,824
+835,882
+405,819
+957,870
+493,721
+1246,164
+935,591
+895,824
+264,455
+99,470
+408,296
+803,400
+1084,126
+1135,63
+835,46
+830,60
+653,721
+1104,453
+525,863
+102,334
+1235,45
+870,121
+375,591
+60,336
+348,880
+895,600
+517,477
+427,526
+100,551
+37,301
+477,880
+0,94
+383,390
+266,718
+212,240
+634,329
+291,493
+976,320
+751,30
+1119,593
+443,753
+1099,645
+79,450
+189,278
+358,745
+870,355
+1064,820
+353,597
+770,630
+157,75
+22,371
+214,493
+465,726
+1205,655
+740,469
+125,49
+1019,849
+735,556
+1148,421
+832,336
+803,338
+848,441
+946,175
+301,149
+115,305
+528,215
+6,208
+6,320
+691,410
+238,658
+16,346
+735,892
+689,725
+661,320
+1136,386
+1153,810
+363,730
+326,464
+321,819
+885,885
+1048,388
+425,9
+127,809
+656,16
+599,280
+74,408
+387,509
+73,724
+293,877
+557,687
+656,878
+1304,320
+1034,865
+704,119
+126,663
+141,656
+914,859
+1230,647
+340,266
+33,501
+1262,352
+505,344
+1283,105
+1198,289
+855,500
+574,871
+540,598
+465,844
+1210,343
+825,96
+290,623
+174,508
+132,539
+867,93
+1101,201
+392,142
+472,126
+552,320
+631,739
+867,473
+763,758
+467,67
+251,269
+1273,301
+619,282
+1148,130
+801,4
+566,136
+1098,94
+1274,47
+333,411
+401,82
+48,352
+1230,522
+907,269
+870,829
+631,683
+406,660
+440,488
+800,798
+244,765
+657,768
+662,94
+33,465
+785,415
+83,450
+1159,355
+653,686
+392,730
+417,352
+691,829
+902,598
+947,282
+242,469
+135,301
+174,834
+816,189
+914,894
+671,562
+460,786
+1079,765
+125,525
+213,430
+480,60
+1086,390
+1111,809
+375,302
+1227,390
+1072,684
+343,494
+443,473
+904,234
+485,45
+1285,86
+977,299
+758,782
+242,425
+460,718
+37,593
+730,486
+559,877
+505,102
+401,812
+231,254
+403,269
+493,238
+1181,479
+189,29
+545,355
+264,439
+547,60
+900,695
+689,393
+1079,254
+408,199
+846,383
+1223,630
+1121,284
+345,666
+441,117
+237,800
+191,525
+1066,255
+552,768
+639,494
+798,705
+1004,189
+1169,861
+686,745
+1121,29
+554,126
+1277,465
+977,432
+711,399
+12,628
+
+fold along x=655
+fold along y=447
+fold along x=327
+fold along y=223
+fold along x=163
+fold along y=111
+fold along x=81
+fold along y=55
+fold along x=40
+fold along y=27
+fold along y=13
+fold along y=6
diff --git a/2021/13/testinput b/2021/13/testinput
new file mode 100644
index 0000000..282114c
--- /dev/null
+++ b/2021/13/testinput
@@ -0,0 +1,21 @@
+6,10
+0,14
+9,10
+0,3
+10,4
+4,11
+6,0
+6,12
+4,1
+0,13
+10,12
+3,4
+3,0
+8,4
+1,10
+2,14
+8,10
+9,0
+
+fold along y=7
+fold along x=5
diff --git a/2021/14/code.tl b/2021/14/code.tl
new file mode 100644
index 0000000..0af2ac7
--- /dev/null
+++ b/2021/14/code.tl
@@ -0,0 +1,48 @@
+(defstruct polym ()
+ input
+ rewrites
+ (memo (hash)))
+
+(defun read-input (: (name "input"))
+ (let ((po (new polym)))
+ (each ((line (file-get-lines name)))
+ (match-case line
+ (`@{x 1}@{y 1} -> @z` (push ^((,(intern-fb x)
+ ,(intern-fb y))
+ ,(intern-fb z))
+ po.rewrites))
+ (`@{x #/.+/}` -> (set po.input (flow x
+ (tuples 1)
+ (mapcar intern-fb))))))
+ po))
+
+(defmeth polym rec1 (po pair depth : (leftmost t))
+ (let ((key ^(,pair ,depth ,leftmost)))
+ (condlet
+ (((re [po.memo key]))
+ re)
+ (((rw (and (plusp (pdec depth))
+ [find pair po.rewrites : car])))
+ (tree-bind ((x y) z) rw
+ (let ((lhist po.(rec1 ^(,x ,z) depth leftmost))
+ (rhist po.(rec1 ^(,z ,y) depth nil)))
+ (set [po.memo key]
+ [hash-uni lhist rhist +]))))
+ (leftmost
+ (hash-zip pair '(1 1)))
+ (t
+ (hash-zip (cdr pair) '(1))))))
+
+(defmeth polym rec (po pairs depth : (leftmost t))
+ (let ((hist (hash)))
+ (each ((p pairs)
+ (c 0))
+ (let ((rhist po.(rec1 p depth (zerop c))))
+ (set hist [hash-uni hist rhist +])))
+ hist))
+
+(defun solve (: (name "input") (depth 10))
+ (let* ((po (read-input name))
+ (hist po.(rec (tuples* 2 po.input) depth)))
+ (- (cdr [find-max hist : cdr])
+ (cdr [find-min hist : cdr]))))
diff --git a/2021/14/codes.tl b/2021/14/codes.tl
new file mode 100644
index 0000000..dcaccba
--- /dev/null
+++ b/2021/14/codes.tl
@@ -0,0 +1,42 @@
+(defstruct polym ()
+ input
+ rewrites
+ (memo (hash)))
+
+(defun read-input (: (name "input"))
+ (let ((po (new polym)))
+ (each ((line (file-get-lines name)))
+ (match-case line
+ (`@a -> @b` (push `@a@b` po.rewrites))
+ (`@{a 1}@b` (set po.input `@a@b`))))
+ po))
+
+(defmeth polym rec1 (po pair depth : (leftmost t))
+ (placelet ((memo [po.memo ^(,pair ,depth ,leftmost)]))
+ (condlet
+ (((re memo))
+ re)
+ (((rw (and (plusp (pdec depth))
+ [find pair po.rewrites starts-with])))
+ (match `@{x 1}@{y 1}@{z 1}` rw
+ (let ((lhist po.(rec1 `@x@z` depth leftmost))
+ (rhist po.(rec1 `@z@y` depth nil)))
+ (set memo [hash-uni lhist rhist +]))))
+ (leftmost
+ (set memo (hash-zip pair '(1 1))))
+ (t
+ (set memo (hash-zip (rest pair) '(1)))))))
+
+(defmeth polym rec (po pairs depth : (leftmost t))
+ (let ((hist (hash)))
+ (each ((p pairs)
+ (c 0))
+ (let ((rhist po.(rec1 p depth (zerop c))))
+ (set hist [hash-uni hist rhist +])))
+ hist))
+
+(defun solve (: (name "input") (depth 10))
+ (let* ((po (read-input name))
+ (hist po.(rec (tuples* 2 po.input) depth)))
+ (- (cdr [find-max hist : cdr])
+ (cdr [find-min hist : cdr]))))
diff --git a/2021/14/input b/2021/14/input
new file mode 100644
index 0000000..4711af4
--- /dev/null
+++ b/2021/14/input
@@ -0,0 +1,102 @@
+VCOPVNKPFOOVPVSBKCOF
+
+NO -> K
+PO -> B
+HS -> B
+FP -> V
+KN -> S
+HV -> S
+KC -> S
+CS -> B
+KB -> V
+OB -> V
+HN -> S
+OK -> N
+PC -> H
+OO -> P
+HF -> S
+CB -> C
+SB -> V
+FN -> B
+PH -> K
+KH -> P
+NB -> F
+KF -> P
+FK -> N
+FB -> P
+FO -> H
+CV -> V
+CN -> P
+BN -> N
+SC -> N
+PB -> K
+VS -> N
+BP -> P
+CK -> O
+PS -> N
+PF -> H
+HB -> S
+VN -> V
+OS -> V
+OC -> O
+BB -> F
+SK -> S
+NF -> F
+FS -> S
+SN -> N
+FC -> S
+BH -> N
+HP -> C
+VK -> F
+CC -> N
+SV -> H
+SO -> F
+HH -> C
+PK -> P
+NV -> B
+KS -> H
+NP -> H
+VO -> C
+BK -> V
+VV -> P
+HK -> B
+CF -> B
+BF -> O
+OV -> B
+OH -> C
+PP -> S
+SP -> S
+CH -> B
+OF -> F
+NK -> F
+FV -> F
+KP -> O
+OP -> O
+SS -> P
+CP -> H
+BO -> O
+KK -> F
+HC -> N
+KO -> V
+CO -> F
+NC -> P
+ON -> P
+KV -> C
+BV -> K
+HO -> F
+PV -> H
+VC -> O
+NH -> B
+PN -> H
+VP -> O
+NS -> N
+NN -> S
+BS -> H
+SH -> P
+VB -> V
+VH -> O
+FH -> K
+FF -> H
+SF -> N
+BC -> H
+VF -> P
diff --git a/2021/14/testinput b/2021/14/testinput
new file mode 100644
index 0000000..b5594dd
--- /dev/null
+++ b/2021/14/testinput
@@ -0,0 +1,18 @@
+NNCB
+
+CH -> B
+HH -> N
+CB -> H
+NH -> C
+HB -> C
+HC -> B
+HN -> C
+NN -> C
+BH -> H
+NC -> B
+NB -> B
+BN -> B
+BB -> N
+BC -> B
+CC -> N
+CN -> C
diff --git a/2021/15/case0 b/2021/15/case0
new file mode 100644
index 0000000..169fdf5
--- /dev/null
+++ b/2021/15/case0
@@ -0,0 +1,10 @@
+1111111111
+9999999991
+9999999991
+9111111111
+9199999999
+9199999999
+9199111119
+9199199919
+9199199919
+9111199911
diff --git a/2021/15/code-orig.tl b/2021/15/code-orig.tl
new file mode 100644
index 0000000..1a1b2f9
--- /dev/null
+++ b/2021/15/code-orig.tl
@@ -0,0 +1,86 @@
+(defstruct (coord x y) ()
+ x y)
+
+(defstruct (info coo dist) ()
+ coo
+ dist
+ prev
+ visited
+
+ (:method equal (inf) inf.dist))
+
+(defstruct board ()
+ w h a
+ (memo (hash))
+
+ (:postinit (bo)
+ (assert (eql bo.w bo.h)))
+
+ (:method lambda (me coo)
+ [[me.a coo.y] coo.x])
+
+ (:method lambda-set (me coo nv)
+ (set [[me.a coo.y] coo.x] nv)))
+
+(defun read-input (: (name "input"))
+ (flow (file-get-lines name)
+ vec-list
+ (new board
+ h (len @1)
+ w (len (first @1))
+ a (mapcar (opip (mapcar chr-digit) vec-list) @1))))
+
+(defmeth board ensure-info (bo inf coo : dist)
+ (unless (or (minusp coo.x) (minusp coo.y)
+ (>= coo.x bo.w) (>= coo.y bo.h))
+ (placelet ((pl [inf coo]))
+ (or pl (set pl (new (info coo dist)))))))
+
+(defmeth board shortest-path (bo start goal)
+ (let* ((inf (hash))
+ (c 0)
+ (que nil)
+ (cur bo.(ensure-info inf start [bo start])))
+ (while (and cur (nequal cur.coo goal))
+ (let* ((coo cur.coo)
+ (ne (remove-if [orf null .visited]
+ (list bo.(ensure-info inf (new (coord coo.x (succ coo.y))))
+ bo.(ensure-info inf (new (coord (succ coo.x) coo.y)))
+ bo.(ensure-info inf (new (coord coo.x (pred coo.y))))
+ bo.(ensure-info inf (new (coord (pred coo.x) coo.y)))))))
+ (each ((n ne))
+ (unless n.dist
+ (set n.dist (+ cur.dist [bo n.coo])
+ n.prev cur)
+ (push n que)))
+ (upd que (remq cur))
+ (set cur.visited t
+ cur (find-min que))))
+ (for (out (x bo.(ensure-info inf goal))) (x out) ((set x x.prev))
+ (push x.coo out))))
+
+(defmeth board blow-up (bo mag)
+ (unless (eql mag 1)
+ (let ((ow bo.w)
+ (oh bo.h))
+ (set bo.w (* mag ow)
+ bo.h (* mag oh))
+ (vec-set-length bo.a bo.h)
+ (each ((y 0..bo.h))
+ (if [bo.a y]
+ (vec-set-length [bo.a y] bo.w)
+ (set [bo.a y] (vector bo.w)))
+ (each ((x 0..bo.w))
+ (let* ((c (+ (trunc x ow) (trunc y oh)))
+ (ox (mod x ow))
+ (oy (mod y oh)))
+ (set [[bo.a y] x]
+ (flow [[bo.a oy] ox] pred (+ c) (mod @1 9) succ)))))))
+ bo)
+
+(defun solve (: (name :) (mag 1))
+ (let* ((bo (read-input name).(blow-up mag))
+ (start (new (coord 0 0)))
+ (goal (new (coord (pred bo.w) (pred bo.h))))
+ (path bo.(shortest-path start goal)))
+ (cons (sum (cdr path) bo) path)))
diff --git a/2021/15/code.tl b/2021/15/code.tl
new file mode 100644
index 0000000..b541a60
--- /dev/null
+++ b/2021/15/code.tl
@@ -0,0 +1,87 @@
+(defstruct (coord x y) ()
+ x y)
+
+(defstruct (info coo dist) ()
+ coo
+ dist
+ prev
+ visited
+
+ (:method equal (inf) inf.dist))
+
+(defstruct board ()
+ w h a
+ (memo (hash))
+
+ (:postinit (bo)
+ (assert (eql bo.w bo.h)))
+
+ (:method lambda (me coo)
+ [[me.a coo.y] coo.x])
+
+ (:method lambda-set (me coo nv)
+ (set [[me.a coo.y] coo.x] nv)))
+
+(defun read-input (: (name "input"))
+ (flow (file-get-lines name)
+ vec-list
+ (new board
+ h (len @1)
+ w (len (first @1))
+ a (mapcar (opip (mapcar chr-digit) vec-list) @1))))
+
+(defmeth board ensure-info (bo inf coo : dist)
+ (unless (or (minusp coo.x) (minusp coo.y)
+ (>= coo.x bo.w) (>= coo.y bo.h))
+ (placelet ((pl [inf coo]))
+ (or pl (set pl (new (info coo dist)))))))
+
+(defmeth board shortest-path (bo start goal)
+ (let* ((inf (hash))
+ (c 0)
+ (que (tree))
+ (cur bo.(ensure-info inf start [bo start])))
+ (while (and cur (nequal cur.coo goal))
+ (let* ((coo cur.coo)
+ (ne (remove-if [orf null .visited]
+ (list bo.(ensure-info inf (new (coord coo.x (succ coo.y))))
+ bo.(ensure-info inf (new (coord (succ coo.x) coo.y)))
+ bo.(ensure-info inf (new (coord coo.x (pred coo.y))))
+ bo.(ensure-info inf (new (coord (pred coo.x) coo.y)))))))
+ (each ((n ne))
+ (unless n.dist
+ (set n.dist (+ cur.dist [bo n.coo])
+ n.prev cur)
+ (tree-insert que n t)))
+ (let ((tn (tree-peek (tree-begin que))))
+ (set cur.visited t
+ cur (key tn))
+ (tree-delete-specific-node que tn))))
+ (for (out (x bo.(ensure-info inf goal))) (x out) ((set x x.prev))
+ (push x.coo out))))
+
+(defmeth board blow-up (bo mag)
+ (unless (eql mag 1)
+ (let ((ow bo.w)
+ (oh bo.h))
+ (set bo.w (* mag ow)
+ bo.h (* mag oh))
+ (vec-set-length bo.a bo.h)
+ (each ((y 0..bo.h))
+ (if [bo.a y]
+ (vec-set-length [bo.a y] bo.w)
+ (set [bo.a y] (vector bo.w)))
+ (each ((x 0..bo.w))
+ (let* ((c (+ (trunc x ow) (trunc y oh)))
+ (ox (mod x ow))
+ (oy (mod y oh)))
+ (set [[bo.a y] x]
+ (flow [[bo.a oy] ox] pred (+ c) (mod @1 9) succ)))))))
+ bo)
+
+(defun solve (: (name :) (mag 1))
+ (let* ((bo (read-input name).(blow-up mag))
+ (start (new (coord 0 0)))
+ (goal (new (coord (pred bo.w) (pred bo.h))))
+ (path bo.(shortest-path start goal)))
+ (cons (sum (cdr path) bo) path)))
diff --git a/2021/15/graph b/2021/15/graph
new file mode 100644
index 0000000..a97b312
--- /dev/null
+++ b/2021/15/graph
@@ -0,0 +1,30 @@
+1-*-1-*-6-3751742
+| | |
+* * *
+| | |
+1-*-3-*-8-1373672
+*
+2136511328
+3694931569
+7463417111
+1319128137
+1359912421
+3125421639
+1293138521
+2311944581
+
+1163751742
+1381373672
+2136511328
+3694931569
+7463417111
+1319128137
+1359912421
+3125421639
+1293138521
+2311944581
+
+128
+25
+45
+7
diff --git a/2021/15/input b/2021/15/input
new file mode 100644
index 0000000..2fb00a8
--- /dev/null
+++ b/2021/15/input
@@ -0,0 +1,100 @@
+9117126765954991531361287887952293985228945954968719768599113229933177321218646689996911474536732399
+9223759878952221676171579911799962387979151219995716217699696127938673831489291395696919969932254989
+3541576911128155121299113222129549287959588382622619513719133924151162841285778821288275724961119944
+6559133231375896721321444531355921461395859117937697179547219275288311254734149251973431135281269159
+1676267562819916395689997881982992332424111621435132141259871861542693472992135679917192317774293128
+8249139898167999696294834861387663883158627396569381992149353912931121947619234731324959354465133393
+7357179973989691178482439911993891132125811578668959789312252688675899921989453929516192661843919197
+4619696469916668547597358979211912998111859144138732228282162541629959265225279899275869118746211343
+9953447549477253881796188328361584296836894253681673583298151169375142116172299791649833153199728127
+6746781992592141396343937891111468593431876292615191122987921959192389783817917672173839828296719999
+9138943966124123291819332993929628638169993945962128621134717995149146955791514983198995871433119683
+5819163188981382448685489916367822515728379179272999893692949943661458236153872599999471496119999333
+9719423138538191938542116779987951211999142299782419116287869943982658286621789697471829675879813256
+9699181696126359195481558113952858412929919992895921913238884884827387595171659273872138379679533591
+4993982621563681889939627931477941336198842897212192543931489597746158398239126972227589994828192999
+2668741998199239119999431871112499961947311948258837213919913418234952325331319559453486297114898498
+1127639615295239423919963661998995345216641693977915377189312819154824929848524771848827299135811811
+8368387172119721672588279993639478972511318945923156162231548169532294139882492179811534898824293433
+8783398963998292816524668577741241713481448273631853599957636719273318298313692157194988481619656618
+2953756999862932299821112664281972119127941479853941118579781188619286791413589268314233994924958219
+3721595414181516593884399118999691998316513129665554615276617573518961968693226371972761423831798176
+1991694811958961555928271245541174192885889591799159659816793825199835199263296631112197219243356537
+8252659533163973655722922376235699717495344481141662818711913921134614993948299831832153649939699789
+4991481114394946826713119671181783791173994371435189998492951985177386891322761246115321579813246554
+6993696939393598438941581694619582924588531988611314975227128981355369857749392159437189417619958138
+7225751179695254891295269821492811764941719129614841461722979146177892692799164911833219318964591993
+1333799929651611111256382193432394899779926422481315934699941139983894338331242127329982789394316531
+8837481279123791791511293941173182698413296717121319418188693999815688934899313263953713912168172818
+2715518187177668788558311556248368519817398834879452159637191987847374713799691792778685985151183163
+2259918816199912192975991922626992158899968292179154972119897541183344185545199271144885417852464384
+4896829916982297819936288191299877891985362698715838913823274968133179284798911359494966988815194363
+2129324329198744948237831472389914912531592491971717854718183863949418918119729287219911292886619189
+1475996352848299913587823871858259582986232951986536913528821944878682992979346487316611181412119533
+8788926799919935991369615497631215917839967981681589392981969115279279799512993478671319169869899122
+9742798185239991887978461721361783139999411599389459591792941389692391799791168329923823769316152161
+9173764598521995899121318191935619363699465981899276491962199879816415838819753987163171115742984632
+7731396437141244238124389792786718327351712492271297983335154292724119492723817435886686622726342678
+9614311948611819439192193259859494925678221999836116159691926837722999383959859996122151658985129189
+9122652146647862919899432718742622765273781311965998133187119169243998185815214999623989171991112561
+2991149875591574422711878572239393988875812296611285397519895686411153557723621141397739842873293893
+2911712393758279823638782882718181196128199519455914978868511911598985898293181751711911218642216689
+1793818819191888913194513765514877471931431423191639139334319868989124214159551117358829997181729622
+9949357949267411491772862121912417767853191411964865383988989611452288776982343996113214944462969295
+7749547939932999936999429979727961593311762124797241581688731949186682939476917299694545222196819348
+1569668325497998539641217919697391265847199126799274979992177877339999721187338499385894391688757142
+4377839628315395229914399726112147897399599948122361917993319944114926999815642921981378665997811872
+9967919912939795941911874237196684126623211793151918221173577223365897891296638491193191626818926319
+6127813499273598122265983738469915367119615465748387155399948195258986878198325321289565931794369882
+3692358924999677389297641337293459814384114353897968978424818882635937221462858992492131591882224132
+1117153982194132689989432355215193973386193185519916139659867292519312272981167852196787981294159611
+2913296211744741423151491188919997626898296293139158939389496861563476184972948824111324969285978154
+1128929154921239399482171919616671311149987887281336195251291973881413496248383216161516996491666581
+6231424962123952786834891961579891914968821849776946573698886133237873812968796971699337136691824314
+5768145442163769781144449818193919983511191477119947369512899413814156936149842825958595364526718158
+8319371581711189818471818895122114868875787691911889164956117362787871116899195295199538719355396986
+9211851663274989616961671498242498986691547331875596867296989919173763994774977221229869868132965914
+5732195914183159346434492634332849997214425121875559893991761889284193689378889285997478557427216191
+4919594673997161317368638349972858474699479813292211191216314518583592781129989799717793478599178914
+1212816992918491286133111869816588759854919992955644799971992763518799489378127378198842317125143175
+9817119772978993827939981311825351117249291295672398359748996481799455529661331151988374128717911198
+6959979697456791979798577971695957796829731637773612123812799821266989181491797352197987941284655891
+1829894844699799799164192911889898589226224122828488548798956836828955569942827199983734198167711532
+5916952789378491793328318724924815938918116221429399311731729455882819747879189851265198441116437193
+2316593981955647388164661498291113142494888583381924456899524788279716191973597227394711639844831189
+3881981741112295799319415597319199117187845593977913194841473581279361128428681978861181928158967816
+3939242263819932783519851991511688491453123846164148517221781892992125524717372977117928596861679911
+4641477457412251293698829869979122228625995879148499396737898889638982142482362649629364938991956974
+3417666478142114314819128729451691124979739715435211656911679678126199443145439652619914181916916386
+9197964843859986424199652481919639895555559646793968117224461359121927495439994851589194986745767199
+1191146713643837513938479919124381959615799437231597888611882549928192193269491499894796168339169992
+6979872799843753778983789714199378797788991933161979219897497929969121145325613894815531148198861891
+2897711394223385969627249728919332712941132392931181791715591273435311267141292629528963749919974818
+2125918421718973999673882616938889788112781219151398836281824826992487716291785514764768419996341848
+8117112532342797719737195144272912273419948528898235213984262216911914853922412891737981226189198334
+8882822942993968884139633296571516319764762815264113984968674415659712333797681255649671289971237799
+6725141179673886293898974248697199412641236288717399983269493559587293483647122119669723819651859959
+1635981511964285563772993596794551919558191915999181325192193378685931492329192296325893816297868828
+2991842229168849265454541381722475797132627864721153611229176825219361112214114198745615199522814789
+9662196198292971249673769196931861972531994792913285496999695698693139738979739822998883371946778731
+1181918926984114515911966772399278413751112259425996784855812239818799793738956869624761863966171537
+8999378549159336384488325775668744969198921949111299734515923966297588431419993827392872615499467238
+8219274184271732972386957524972971338913988119687169636991229178984184952396926742299916161189181478
+7841981498859866989959419399266132122945925192193395264118954251326349873819169726719525916228413529
+1189765873965613399337499824992558892383441129519167958433888816632944688989791799265757192441191821
+1122474698626225978191978983332813388675458997571911911591189133134719817996136961827365281919585249
+9519433249611991278178319662998171623744296811698481199481493878654989641277211912555645876224759575
+6125712149818157123747721394932661689175392123561445398732981771894674399674385915323594549791118229
+9475311931154529515111211948114624455572817339939811952455255144919686927246823239177969193595165495
+6922293775128388772696845128455845794498599788218748614476199937135329672919912919134897925229848914
+2891219869495424258111637249312515345839111989928477967764594159826818397866381991698227675347949931
+9197372475857939168321499153862716767719999947324714971881142347989981393496624535728827564155699898
+8294523819699999172283151339392979985525768564995228999556114292196329719229999257932271983447882795
+1939243157255769865891729948999177881918547399793134894519417939828591196633959298444827973314731911
+2987118759793419159816857586286875932941481119368122639419833371776521998373714251159949852912988542
+2899137888528523774811712997118913916121861528375892921143642282799875121339226945497819958922912934
+6821975883666159111294417189613823241844761788648899421981336795385271598994988991711356515994498997
+1145919998791266421889855551242212544911939312439931545382428359422871391568759927877629148945198935
+7928248141712639396631551112398785717846351616999228378691195976769815744656987513118218637488928521
+1684838399588648881327586957199874792142167832618795919593955245946215969749317899549939164939781974
+8283891211961198885189675761681423122591798322135234799979215759171724989419131318722297222491939131
diff --git a/2021/15/rubbish.tl b/2021/15/rubbish.tl
new file mode 100644
index 0000000..e483dc1
--- /dev/null
+++ b/2021/15/rubbish.tl
@@ -0,0 +1,99 @@
+
+(defmeth board depth-search (bo mincost cur goal gpath lpath depth)
+ (unless (or (memqual cur lpath)
+ (memqual cur gpath)
+ (minusp cur.x)
+ (minusp cur.y)
+ (>= cur.x bo.w)
+ (>= cur.y bo.h))
+ #;(prinl ^(trying ,cur))
+ (push cur lpath)
+ (if (or (zerop (pdec depth)) (equal cur goal))
+ (let ((cost (sum lpath bo)))
+ (when (or (null mincost.val) (< cost mincost.val))
+ #;(prinl ^(,cost ,lpath))
+ (set mincost.val cost
+ mincost.path lpath)))
+ (progn
+ bo.(depth-search mincost (new (coord cur.x (succ cur.y)))
+ goal gpath lpath depth)
+ bo.(depth-search mincost (new (coord (succ cur.x) cur.y))
+ goal gpath lpath depth)
+ bo.(depth-search mincost (new (coord cur.x (pred cur.y)))
+ goal gpath lpath depth)
+ bo.(depth-search mincost (new (coord (pred cur.x) cur.y))
+ goal gpath lpath depth)))))
+
+(defmeth board search (bo gmincost cur goal gpath lookahead)
+ (unless (memqual cur gpath)
+ (if (equal cur goal)
+ (set gmincost.val (+ (sum gpath bo) (- [bo cur] [bo goal]))
+ gmincost.path gpath)
+ (let ((lmincost (new cost)))
+ bo.(depth-search lmincost cur goal gpath nil lookahead)
+ (whenlet ((next [lmincost.path -2]))
+ (prinl next)
+ bo.(search gmincost next goal (cons cur gpath) lookahead))))))
+
+(defun solve-one (: (name :))
+ (let ((bo (read-input name))
+ (mincost (new cost)))
+ bo.(search mincost
+ (new (coord 0 0))
+ (new (coord (pred bo.w) (pred bo.h)))
+ nil
+ 13)
+ mincost))
+
+(defmeth board fill-costs (bo lim)
+ (let ((goal (new (coord (pred bo.w) (pred bo.h)))))
+ (labels ((rec (coo path xmin ymin xmax ymax)
+ (unless (or (memqual coo path)
+ (< coo.x xmin)
+ (< coo.y ymin)
+ (>= coo.x bo.w)
+ (>= coo.y bo.h))
+ (push coo path)
+ (placelet ((memo [bo.memo coo]))
+ (or memo
+ (if (equal coo goal)
+ (set memo (new cost
+ coo coo
+ val 0
+ path (list goal))))
+ (iflet ((next (flow
+ (vec (rec (new (coord coo.x (succ coo.y)))
+ path xmin ymin xmax ymax)
+ (rec (new (coord (succ coo.x) coo.y))
+ path xmin ymin xmax ymax)
+ (rec (new (coord coo.x (pred coo.y)))
+ path xmin ymin xmax ymax)
+ (rec (new (coord (pred coo.x) coo.y))
+ path xmin ymin xmax ymax))
+ (remq nil)))
+ (min [find-min next : .val]))
+ (set memo
+ (new cost
+ coo coo
+ val (+ [bo coo] min.val)
+ path (cons coo min.path)))))))))
+ (each ((k (max bo.w bo.h)..0))
+ (each ((y bo.h..k))
+ (let ((coo (new (coord k y)))
+ (xmin (max 0 (- k lim)))
+ (xmax (min bo.w (+ k lim))))
+ (prinl coo)
+ (set [bo.memo coo]
+ (rec coo nil xmin (max 0 (- y lim)) xmax (min bo.h (+ y lim))))))
+ (each ((x bo.w..k))
+ (let ((coo (new (coord x k)))
+ (ymin (max 0 (- k lim)))
+ (ymax (min bo.h (+ k lim))))
+ (prinl coo)
+ (set [bo.memo coo]
+ (rec coo nil (max 0 (- x lim)) ymin (min bo.w (+ x lim)) ymax))))))))
+
+(defun solve-one-bad (: (name :))
+ (let ((bo (read-input name)))
+ bo.(fill-costs 0)
+ [bo.memo (new (coord 0 0))]))
diff --git a/2021/15/small0 b/2021/15/small0
new file mode 100644
index 0000000..7bba1fe
--- /dev/null
+++ b/2021/15/small0
@@ -0,0 +1,5 @@
+11111
+11111
+11111
+11111
+11111
diff --git a/2021/15/small1 b/2021/15/small1
new file mode 100644
index 0000000..06d3c6a
--- /dev/null
+++ b/2021/15/small1
@@ -0,0 +1,5 @@
+11111
+99191
+11111
+19999
+11111
diff --git a/2021/15/small2 b/2021/15/small2
new file mode 100644
index 0000000..ed6095f
--- /dev/null
+++ b/2021/15/small2
@@ -0,0 +1,9 @@
+111111111
+199999991
+199999991
+199999991
+199999991
+199999991
+199999991
+199999991
+111111191
diff --git a/2021/15/small3 b/2021/15/small3
new file mode 100644
index 0000000..9298e28
--- /dev/null
+++ b/2021/15/small3
@@ -0,0 +1,9 @@
+111111111
+199999991
+199999991
+199999991
+199999991
+199999991
+199999991
+199999999
+111111111
diff --git a/2021/15/testinput b/2021/15/testinput
new file mode 100644
index 0000000..ab80887
--- /dev/null
+++ b/2021/15/testinput
@@ -0,0 +1,10 @@
+1163751742
+1381373672
+2136511328
+3694931569
+7463417111
+1319128137
+1359912421
+3125421639
+1293138521
+2311944581
diff --git a/2021/15/testinput2 b/2021/15/testinput2
new file mode 100644
index 0000000..e1ea085
--- /dev/null
+++ b/2021/15/testinput2
@@ -0,0 +1,50 @@
+11637517422274862853338597396444961841755517295286
+13813736722492484783351359589446246169155735727126
+21365113283247622439435873354154698446526571955763
+36949315694715142671582625378269373648937148475914
+74634171118574528222968563933317967414442817852555
+13191281372421239248353234135946434524615754563572
+13599124212461123532357223464346833457545794456865
+31254216394236532741534764385264587549637569865174
+12931385212314249632342535174345364628545647573965
+23119445813422155692453326671356443778246755488935
+22748628533385973964449618417555172952866628316397
+24924847833513595894462461691557357271266846838237
+32476224394358733541546984465265719557637682166874
+47151426715826253782693736489371484759148259586125
+85745282229685639333179674144428178525553928963666
+24212392483532341359464345246157545635726865674683
+24611235323572234643468334575457944568656815567976
+42365327415347643852645875496375698651748671976285
+23142496323425351743453646285456475739656758684176
+34221556924533266713564437782467554889357866599146
+33859739644496184175551729528666283163977739427418
+35135958944624616915573572712668468382377957949348
+43587335415469844652657195576376821668748793277985
+58262537826937364893714847591482595861259361697236
+96856393331796741444281785255539289636664139174777
+35323413594643452461575456357268656746837976785794
+35722346434683345754579445686568155679767926678187
+53476438526458754963756986517486719762859782187396
+34253517434536462854564757396567586841767869795287
+45332667135644377824675548893578665991468977611257
+44961841755517295286662831639777394274188841538529
+46246169155735727126684683823779579493488168151459
+54698446526571955763768216687487932779859814388196
+69373648937148475914825958612593616972361472718347
+17967414442817852555392896366641391747775241285888
+46434524615754563572686567468379767857948187896815
+46833457545794456865681556797679266781878137789298
+64587549637569865174867197628597821873961893298417
+45364628545647573965675868417678697952878971816398
+56443778246755488935786659914689776112579188722368
+55172952866628316397773942741888415385299952649631
+57357271266846838237795794934881681514599279262561
+65719557637682166874879327798598143881961925499217
+71484759148259586125936169723614727183472583829458
+28178525553928963666413917477752412858886352396999
+57545635726865674683797678579481878968159298917926
+57944568656815567976792667818781377892989248891319
+75698651748671976285978218739618932984172914319528
+56475739656758684176786979528789718163989182927419
+67554889357866599146897761125791887223681299833479
diff --git a/2021/16/code.tl b/2021/16/code.tl
new file mode 100644
index 0000000..8f2016e
--- /dev/null
+++ b/2021/16/code.tl
@@ -0,0 +1,101 @@
+(defstruct bitstream ()
+ bf
+ st
+ pfx
+ (count 0))
+
+(defstruct packet ()
+ version
+ type
+ payload)
+
+(defmeth bitstream read-file (bs : (name "input"))
+ bs.(read-string (file-get-string name)))
+
+(defmeth bitstream read-string (bs s)
+ (set bs.bf (buf-uint (toint s 16))
+ bs.st (make-buf-stream bs.bf))
+ bs.(ensure-prefix 24))
+
+(defmeth bitstream ensure-prefix (bs n)
+ (whilet ((b (and (< (len bs.pfx) n) (get-byte bs.st))))
+ (upd bs.pfx (nconc @1 (flow b (+ 256) (digits @1 2) cdr))))
+ bs)
+
+(defmeth bitstream set-pfx (bs npfx)
+ (placelet ((pfx (read-once bs.pfx))
+ (count (read-once bs.count)))
+ (while (neq pfx npfx)
+ (inc count)
+ (upd pfx cdr)))
+ bs.(ensure-prefix 24))
+
+(defmeth bitstream drop-zeros (bs)
+ (while-match (0 . @rest) bs.pfx
+ bs.(set-pfx rest))
+ bs)
+
+(defmacro val (. bits)
+ ^(poly 2 (list ,*bits)))
+
+(defmeth bitstream parse-header (bs)
+ (match (@v2 @v1 @v0 @t2 @t1 @t0 . @rest)
+ bs.pfx
+ bs.(set-pfx rest)
+ (new packet
+ version (val v2 v1 v0)
+ type (val t2 t1 t0))))
+
+(defmeth packet parse-payload (pk bs)
+ (caseq pk.type
+ (4 (let ((value 0))
+ (while-match (@more @v3 @v2 @v1 @v0 . @rest) bs.pfx
+ bs.(set-pfx rest)
+ (upd value (* 16) (+ (val v3 v2 v1 v0)))
+ (if (zerop more)
+ (return)))
+ (set pk.payload value)))
+ (t (match-case bs.pfx
+ ((0 . @rest)
+ bs.(set-pfx (drop 15 rest))
+ (let ((nbits (poly 2 (take 15 rest)))
+ (count bs.count))
+ (set pk.payload
+ (build
+ (while (< (- bs.count count) nbits)
+ (add bs.(parse-header).(parse-payload bs)))))))
+ ((1 . @rest)
+ bs.(set-pfx (drop 11 rest))
+ (let ((npkt (poly 2 (take 11 rest))))
+ (set pk.payload
+ (build
+ (dotimes (i npkt)
+ (add bs.(parse-header).(parse-payload bs))))))))))
+ pk)
+
+(defmeth packet version-sum (pk)
+ (+ pk.version
+ (ifa (listp pk.payload)
+ (sum it .(version-sum))
+ 0)))
+
+(defun get-packet (: (name "input"))
+ (let* ((bs (new bitstream).(read-file name).(drop-zeros)))
+ bs.(parse-header).(parse-payload bs)))
+
+(defun compile-packet (pk)
+ (let ((mathfun (relate '(0 1 2 3) '(+ * min max) nil))
+ (relfun (relate '(5 6 7) '(> < =) nil)))
+ (match-case pk
+ (@(struct packet type 4 payload @(integerp @literal)) literal)
+ (@(struct packet type @(@fun [mathfun]) payload @args) ^(,fun ,*[mapcar compile-packet args]))
+ (@(struct packet type @(@fun [relfun]) payload @args) ^(if (,fun ,*[mapcar compile-packet args]) 1 0))
+ (@else (error "invalid syntax ~s" else)))))
+
+(defun solve-one (: (name :))
+ (let ((pk (get-packet name)))
+ pk.(version-sum)))
+
+(defun solve-two (: (name :))
+ (let ((pk (get-packet name)))
+ (eval (compile-packet pk))))
diff --git a/2021/16/input b/2021/16/input
new file mode 100644
index 0000000..10fa873
--- /dev/null
+++ b/2021/16/input
@@ -0,0 +1 @@
+820D4100A1000085C6E8331F8401D8E106E1680021708630C50200A3BC01495B99CF6852726A88014DC9DBB30798409BBDF5A4D97F5326F050C02F9D2A971D9B539E0C93323004B4012960E9A5B98600005DA7F11AFBB55D96AFFBE1E20041A64A24D80C01E9D298AF0E22A98027800BD4EE3782C91399FA92901936E0060016B82007B0143C2005280146005300F7840385380146006900A72802469007B0001961801E60053002B2400564FFCE25FEFE40266CA79128037500042626C578CE00085C718BD1F08023396BA46001BF3C870C58039587F3DE52929DFD9F07C9731CC601D803779CCC882767E668DB255D154F553C804A0A00DD40010B87D0D6378002191BE11C6A914F1007C8010F8B1122239803B04A0946630062234308D44016CCEEA449600AC9844A733D3C700627EA391EE76F9B4B5DA649480357D005E622493112292D6F1DF60665EDADD212CF8E1003C29193E4E21C9CF507B910991E5A171D50092621B279D96F572A94911C1D200FA68024596EFA517696EFA51729C9FB6C64019250034F3F69DD165A8E33F7F919802FE009880331F215C4A1007A20C668712B685900804ABC00D50401C89715A3B00021516E164409CE39380272B0E14CB1D9004632E75C00834DB64DB4980292D3918D0034F3D90C958EECD8400414A11900403307534B524093EBCA00BCCD1B26AA52000FB4B6C62771CDF668E200CC20949D8AE2790051133B2ED005E2CC953FE1C3004EC0139ED46DBB9AC9C2655038C01399D59A3801F79EADAD878969D8318008491375003A324C5A59C7D68402E9B65994391A6BCC73A5F2FEABD8804322D90B25F3F4088F33E96D74C0139CF6006C0159BEF8EA6FBE3A9CEC337B859802B2AC9A0084C9DCC9ECD67DD793004E669FA2DE006EC00085C558C5134001088E308A20