Compare commits

...

13 commits

16 changed files with 2400 additions and 1 deletions

2
2021/data/day3.expected Normal file
View file

@ -0,0 +1,2 @@
3895776
7928162

1000
2021/data/day3.input Normal file

File diff suppressed because it is too large Load diff

2
2021/data/day4.expected Normal file
View file

@ -0,0 +1,2 @@
58374
11377

601
2021/data/day4.input Normal file
View file

@ -0,0 +1,601 @@
26,38,2,15,36,8,12,46,88,72,32,35,64,19,5,66,20,52,74,3,59,94,45,56,0,6,67,24,97,50,92,93,84,65,71,90,96,21,87,75,58,82,14,53,95,27,49,69,16,89,37,13,1,81,60,79,51,18,48,33,42,63,39,34,62,55,47,54,23,83,77,9,70,68,85,86,91,41,4,61,78,31,22,76,40,17,30,98,44,25,80,73,11,28,7,99,29,57,43,10
57 12 60 96 93
73 87 63 70 91
74 32 43 67 46
59 34 5 35 82
53 40 55 29 1
48 71 59 45 63
13 42 23 95 39
84 82 10 29 4
16 91 32 92 62
99 33 20 21 3
51 20 32 30 90
86 88 89 1 73
5 64 78 81 22
95 50 7 27 17
39 82 46 35 92
2 65 21 77 97
50 46 38 99 82
22 1 24 63 70
8 32 80 98 35
57 67 25 81 18
64 7 26 44 14
42 71 19 22 0
4 36 51 25 6
69 59 90 15 88
85 65 32 76 70
8 69 75 42 44
64 25 72 71 34
2 94 81 14 38
97 89 59 23 88
57 70 13 1 51
93 94 26 11 35
63 57 84 10 92
12 29 78 65 64
54 75 61 50 81
13 90 2 66 99
10 21 39 24 56
90 49 25 80 59
41 72 47 74 79
9 89 42 92 31
20 1 32 58 83
81 11 58 2 69
79 23 60 8 63
94 9 0 45 34
36 31 61 71 74
51 48 59 99 70
66 47 88 16 18
35 75 54 26 77
23 55 33 3 19
82 71 57 80 45
22 8 40 76 20
8 5 95 86 76
49 21 82 78 77
12 38 61 85 4
14 54 42 40 39
69 66 1 0 7
85 66 96 45 64
25 55 36 76 37
82 61 29 47 54
73 94 3 59 24
71 62 31 98 79
84 10 60 61 97
75 90 95 6 8
93 89 65 70 80
35 15 46 55 77
52 3 74 39 36
80 24 59 71 52
17 43 45 8 6
58 22 32 46 98
48 3 56 31 77
97 28 55 0 76
51 98 12 49 19
28 94 9 97 85
5 78 47 93 24
67 0 37 81 76
77 48 15 69 50
34 45 5 80 14
82 42 63 2 86
3 95 54 74 69
46 27 49 92 66
0 85 98 83 17
41 99 93 62 96
90 30 10 5 94
98 32 83 78 25
76 27 29 19 35
58 91 34 31 3
31 1 24 96 36
58 12 59 57 92
84 5 55 49 41
54 72 70 95 88
66 50 22 35 15
35 57 69 13 93
34 62 28 26 36
6 64 47 74 45
0 32 19 33 44
65 25 90 91 1
57 96 70 15 89
7 65 29 12 34
40 25 36 81 86
58 39 27 79 59
19 91 47 6 11
60 74 67 87 68
80 53 42 91 89
11 19 8 78 31
4 6 30 10 90
64 41 27 59 12
45 0 86 81 34
8 29 53 12 32
89 74 64 26 96
60 13 87 35 73
52 69 23 46 40
43 35 1 59 40
63 74 7 53 94
39 42 8 84 27
66 65 46 82 80
61 76 13 31 45
38 4 51 76 5
36 57 3 86 84
83 37 60 67 52
0 70 7 19 72
62 99 9 75 58
95 47 78 27 14
50 82 17 15 22
1 76 64 73 71
24 26 42 79 55
36 40 43 81 59
13 7 60 49 87
30 31 99 19 82
91 88 53 96 97
37 11 47 32 81
86 94 45 71 38
64 42 19 6 69
33 2 61 98 55
20 48 5 82 56
78 11 65 59 74
85 72 1 54 29
76 56 84 34 83
16 26 33 50 3
85 20 87 31 51
62 7 28 96 8
81 57 89 44 58
92 49 58 8 45
47 89 48 91 71
53 67 37 59 88
24 69 96 61 16
2 6 68 95 60
99 60 39 96 0
62 14 77 70 47
72 98 66 42 58
85 19 12 23 44
68 28 51 94 82
59 32 45 99 92
96 36 30 87 9
61 54 71 94 22
76 4 62 20 2
40 18 43 70 44
22 54 77 12 3
5 11 41 19 58
49 51 75 24 63
42 20 43 92 69
62 36 15 25 80
93 40 48 21 10
0 83 86 31 65
52 7 17 67 72
95 28 63 99 47
51 22 85 55 44
43 26 86 80 94
93 66 84 90 61
91 58 71 73 89
9 72 81 48 54
11 60 36 25 70
33 42 73 20 69
15 12 27 72 14
93 30 89 86 22
77 25 80 85 74
66 78 0 49 82
37 84 46 86 39
55 31 96 17 43
12 33 45 97 9
44 57 25 77 78
5 73 81 35 58
19 41 87 94 59
97 84 78 52 77
70 15 91 53 1
71 47 82 35 99
25 55 58 39 29
29 74 31 73 72
23 10 83 63 25
18 26 79 35 65
59 44 98 45 20
67 7 87 28 11
83 89 92 55 72
32 6 78 93 49
66 77 5 60 61
85 57 29 97 65
86 84 48 20 75
85 82 83 66 86
64 61 77 38 84
1 68 4 18 72
56 97 37 98 74
44 14 78 52 93
30 73 72 24 51
78 3 97 39 5
90 42 58 96 17
33 95 44 27 1
80 16 84 54 99
92 88 79 14 10
24 52 80 46 51
11 31 35 53 25
44 54 63 33 93
87 38 15 64 4
14 25 61 40 95
34 17 97 38 26
64 90 45 91 65
8 50 23 11 74
32 33 22 88 28
8 32 94 72 74
27 29 22 2 76
58 54 80 5 35
36 24 83 59 25
21 31 48 39 4
56 13 22 53 72
61 60 81 87 86
7 74 98 28 11
67 38 91 23 0
42 84 24 3 47
29 98 43 45 30
86 50 15 60 11
18 34 8 67 24
36 97 69 27 79
35 87 52 55 61
40 50 30 75 72
1 62 85 21 11
80 10 91 7 2
27 31 73 25 29
63 65 55 87 23
12 68 47 77 76
98 30 6 51 80
22 85 88 99 24
35 90 82 18 37
17 27 34 54 43
85 46 35 16 45
4 6 96 9 61
44 90 64 29 50
76 38 69 80 28
27 23 51 8 7
72 8 62 61 83
0 30 92 29 7
86 28 54 52 5
32 97 82 68 31
76 69 22 12 13
66 67 1 36 94
80 99 49 47 38
76 95 30 13 19
83 21 45 44 43
29 91 14 20 98
8 80 3 82 99
62 41 47 6 27
12 72 76 81 36
30 7 67 90 5
85 31 83 49 19
25 91 86 47 27
69 74 20 17 97
59 45 87 28 75
49 94 63 33 9
8 66 2 30 32
69 58 41 84 5
27 2 22 65 88
63 96 90 17 85
26 52 86 20 8
3 9 59 50 57
80 85 90 5 56
66 57 76 65 62
81 74 15 38 32
0 75 61 16 79
96 50 8 86 1
52 21 98 54 94
73 90 87 58 50
38 39 30 69 82
55 12 81 48 29
93 23 91 47 28
92 14 3 1 19
18 27 91 62 86
61 80 49 53 97
77 98 52 0 8
17 54 85 59 51
49 45 38 70 33
96 18 63 5 99
65 58 29 91 19
78 7 98 39 17
31 15 13 35 75
55 50 58 96 94
67 72 4 40 90
59 31 15 78 81
1 80 56 34 20
27 52 88 75 53
0 5 91 65 72
53 42 4 50 25
13 52 81 79 92
46 89 55 58 95
19 77 30 36 18
38 97 86 69 44
70 52 14 19 29
9 36 96 24 80
84 22 32 72 48
28 3 46 42 87
94 93 31 33 38
21 30 34 69 35
1 10 55 79 57
54 28 44 78 73
8 20 45 41 23
32 13 49 80 68
41 95 84 74 57
15 61 5 77 67
53 54 29 51 75
24 66 36 88 90
74 49 19 2 66
94 45 30 84 37
7 24 22 87 60
13 40 57 9 1
56 42 92 67 27
29 7 97 22 36
80 77 92 3 67
48 54 73 51 41
28 8 55 24 4
13 11 66 5 86
76 16 8 71 92
23 61 53 27 43
25 6 17 32 64
40 69 21 84 93
89 30 55 90 41
86 22 81 13 33
35 87 82 77 71
96 65 37 62 51
16 72 36 93 23
84 44 26 66 27
4 73 52 35 43
39 9 96 34 70
19 67 38 10 54
21 7 36 13 90
84 28 59 57 75
55 7 32 68 97
10 56 46 28 66
74 81 18 73 26
44 76 13 35 61
90 36 45 64 58
96 62 97 87 95
45 78 38 84 41
91 19 88 25 22
12 27 31 92 5
15 83 7 53 71
31 17 96 6 47
3 90 27 89 75
53 39 62 82 13
52 34 23 83 87
19 67 50 98 84
96 3 70 17 42
50 74 65 53 31
52 80 18 26 77
29 57 95 25 81
88 92 55 13 28
63 34 56 1 4
40 97 10 5 50
96 55 15 68 37
43 33 89 72 3
11 88 44 86 2
65 44 24 34 41
1 68 67 6 26
27 88 73 25 9
55 56 16 48 29
33 18 77 3 94
91 75 35 33 56
96 19 69 81 53
25 14 32 74 22
24 6 89 42 90
9 2 77 67 20
19 97 36 78 71
16 26 99 23 92
10 68 74 90 88
30 60 96 11 34
8 76 35 53 22
84 15 76 31 63
1 34 96 70 35
66 57 71 26 61
83 41 74 85 60
16 28 30 23 49
72 88 56 92 86
12 44 71 47 30
39 53 4 46 45
38 5 9 35 25
8 61 13 50 82
62 92 49 21 95
70 47 73 74 56
17 89 0 39 60
42 99 13 63 67
43 16 11 20 84
13 30 59 84 12
52 88 79 62 29
99 39 95 55 70
80 46 31 89 69
74 71 65 3 38
47 86 21 24 22
0 62 69 38 59
27 10 41 81 92
14 51 35 13 17
30 15 7 71 70
25 26 29 66 32
68 46 77 45 86
14 15 90 40 22
6 36 17 76 1
80 55 83 98 79
98 76 58 27 39
45 90 56 46 69
10 41 54 82 25
94 86 89 33 79
16 30 87 24 83
66 28 93 91 68
71 51 22 10 42
29 20 77 17 8
55 39 89 72 12
98 78 65 48 41
49 25 80 64 99
90 9 40 76 63
60 93 46 4 27
17 0 42 33 28
59 26 18 69 75
35 0 76 58 31
87 17 42 13 33
70 67 61 52 12
59 85 64 80 1
4 73 99 55 48
40 73 94 80 90
9 93 17 51 62
96 0 57 82 47
86 27 64 95 84
16 99 37 41 44
8 96 31 26 50
20 69 75 82 89
94 42 38 78 35
83 13 45 62 43
97 14 34 17 47
35 88 38 7 97
8 79 51 74 26
60 22 53 5 33
63 23 69 0 83
21 44 91 95 18
64 77 4 0 15
80 66 9 16 5
75 8 18 40 91
72 1 49 60 97
14 24 34 65 92
84 75 31 56 55
17 92 48 45 89
88 52 10 90 47
91 97 6 39 79
99 65 11 42 93
7 82 10 88 49
11 66 54 3 53
4 73 71 42 92
22 75 84 16 48
5 94 79 96 45
20 87 16 25 9
15 70 19 72 56
71 37 69 2 62
76 97 41 8 92
40 65 86 0 32
81 48 14 75 4
70 30 6 74 62
15 28 55 22 63
36 32 35 86 71
29 47 59 18 78
10 35 27 14 64
43 19 86 71 36
32 79 9 51 91
17 67 26 41 56
15 1 95 13 65
74 79 22 30 46
80 55 57 14 37
59 88 40 83 56
63 10 97 64 7
77 61 53 91 20
53 81 13 72 67
79 10 71 11 8
0 99 60 20 4
7 45 89 66 98
50 36 80 57 5
5 7 35 4 29
28 65 31 86 33
66 98 75 13 92
38 67 80 46 11
9 15 57 71 32
21 33 22 77 5
0 6 59 37 69
50 45 32 60 96
9 39 28 56 57
34 46 43 52 25
67 11 21 53 60
52 58 54 94 47
84 46 72 81 16
31 51 23 36 97
80 43 75 99 79

2
2021/data/day5.expected Normal file
View file

@ -0,0 +1,2 @@
5442
19571

500
2021/data/day5.input Normal file
View file

@ -0,0 +1,500 @@
62,963 -> 844,181
58,85 -> 917,944
137,76 -> 137,347
453,125 -> 347,19
178,65 -> 977,864
447,360 -> 62,745
723,326 -> 156,893
47,497 -> 107,437
387,491 -> 340,491
58,477 -> 283,252
86,351 -> 562,827
215,172 -> 539,172
496,801 -> 496,63
546,412 -> 232,98
621,807 -> 481,807
471,20 -> 618,20
175,283 -> 175,467
19,283 -> 19,290
159,137 -> 159,11
593,181 -> 543,181
167,976 -> 929,976
730,782 -> 959,782
713,285 -> 713,880
583,144 -> 583,296
39,61 -> 961,983
778,81 -> 604,81
70,560 -> 70,889
85,129 -> 666,710
689,688 -> 632,688
76,52 -> 903,879
510,543 -> 22,55
510,935 -> 470,935
780,357 -> 780,602
440,349 -> 710,79
934,801 -> 412,801
979,25 -> 35,969
379,527 -> 379,76
243,524 -> 243,664
534,945 -> 11,422
198,367 -> 224,367
871,451 -> 456,451
226,231 -> 939,231
686,354 -> 740,300
543,68 -> 340,68
506,160 -> 319,347
177,25 -> 177,603
337,450 -> 724,450
421,519 -> 676,519
858,976 -> 179,297
236,222 -> 236,250
254,242 -> 254,626
859,243 -> 23,243
89,982 -> 979,92
58,758 -> 101,801
930,483 -> 587,826
667,717 -> 667,762
512,816 -> 845,816
17,501 -> 17,760
345,61 -> 847,61
531,840 -> 618,840
67,748 -> 262,748
548,461 -> 163,846
934,142 -> 169,907
119,931 -> 580,470
769,916 -> 457,604
587,458 -> 93,458
109,850 -> 768,191
225,129 -> 160,64
544,163 -> 544,476
304,594 -> 61,351
510,396 -> 510,741
772,210 -> 772,889
867,415 -> 721,269
466,266 -> 466,44
305,609 -> 305,237
563,962 -> 451,962
566,402 -> 28,940
889,717 -> 891,717
754,545 -> 313,545
930,976 -> 209,255
70,911 -> 692,289
737,37 -> 958,37
652,566 -> 720,634
776,551 -> 370,957
484,476 -> 820,476
119,420 -> 639,420
394,964 -> 394,221
340,767 -> 964,143
715,289 -> 481,55
236,389 -> 826,389
747,642 -> 33,642
583,351 -> 244,690
609,17 -> 609,680
460,365 -> 668,365
519,180 -> 929,590
206,45 -> 782,45
507,185 -> 386,306
16,12 -> 982,978
31,348 -> 320,348
54,975 -> 947,82
844,714 -> 870,714
677,965 -> 677,699
387,699 -> 387,26
329,479 -> 189,479
970,708 -> 538,708
565,434 -> 565,623
748,737 -> 748,497
255,984 -> 255,600
146,59 -> 932,845
191,929 -> 423,929
316,409 -> 802,409
208,560 -> 559,209
885,237 -> 135,987
477,486 -> 260,486
845,59 -> 845,811
225,369 -> 162,369
858,678 -> 858,362
162,972 -> 27,972
828,26 -> 283,571
670,48 -> 114,604
732,487 -> 620,487
570,575 -> 14,19
113,203 -> 162,154
374,702 -> 374,452
850,575 -> 535,575
841,133 -> 841,474
976,960 -> 642,960
177,428 -> 177,246
969,289 -> 589,289
787,842 -> 731,786
743,709 -> 336,709
15,914 -> 299,630
863,952 -> 17,952
586,889 -> 586,512
442,128 -> 436,128
633,367 -> 79,921
21,990 -> 257,990
829,297 -> 829,103
975,633 -> 879,633
946,887 -> 72,13
531,720 -> 123,312
84,954 -> 815,223
989,982 -> 257,982
669,417 -> 928,158
128,935 -> 87,976
692,850 -> 191,850
686,856 -> 686,259
135,396 -> 473,58
837,206 -> 629,206
751,227 -> 751,900
190,617 -> 190,502
850,265 -> 254,265
229,587 -> 325,491
980,747 -> 465,232
54,375 -> 439,375
737,844 -> 711,844
533,219 -> 123,629
232,805 -> 232,798
911,441 -> 911,160
80,294 -> 80,527
880,533 -> 590,533
674,84 -> 674,670
956,440 -> 554,842
24,939 -> 890,73
516,183 -> 145,554
71,584 -> 71,766
629,173 -> 643,187
34,360 -> 639,965
983,871 -> 983,682
986,590 -> 986,327
769,986 -> 130,986
392,192 -> 70,192
577,379 -> 635,379
243,664 -> 162,664
273,987 -> 273,192
251,548 -> 558,855
989,736 -> 989,611
400,697 -> 134,431
646,923 -> 646,841
768,782 -> 386,782
93,973 -> 939,127
489,91 -> 489,551
313,683 -> 248,748
986,61 -> 201,846
322,413 -> 737,413
567,716 -> 567,614
198,624 -> 439,624
402,198 -> 147,453
897,352 -> 897,298
773,379 -> 773,19
373,256 -> 931,814
690,796 -> 543,796
884,368 -> 464,368
136,864 -> 622,378
458,569 -> 458,254
491,462 -> 491,412
558,340 -> 73,340
980,52 -> 980,605
126,609 -> 390,345
437,659 -> 17,659
53,928 -> 982,928
389,591 -> 389,832
464,46 -> 464,754
646,680 -> 646,988
919,159 -> 109,969
334,75 -> 219,75
976,639 -> 976,685
264,773 -> 128,773
787,771 -> 699,771
415,124 -> 549,124
468,71 -> 468,701
815,121 -> 797,121
619,95 -> 610,104
886,294 -> 120,294
148,136 -> 148,314
816,971 -> 454,971
888,733 -> 431,733
59,836 -> 840,55
52,965 -> 962,55
989,982 -> 19,12
697,818 -> 185,306
883,638 -> 481,638
429,285 -> 170,26
516,507 -> 516,301
767,102 -> 61,808
764,793 -> 209,238
568,411 -> 261,718
706,622 -> 685,622
226,110 -> 790,674
544,429 -> 544,334
794,588 -> 794,792
804,738 -> 782,738
370,552 -> 370,189
960,275 -> 644,275
133,896 -> 686,896
12,986 -> 987,11
978,973 -> 69,64
92,465 -> 62,465
733,57 -> 18,57
110,845 -> 110,272
123,935 -> 123,499
37,960 -> 986,11
332,209 -> 344,221
237,279 -> 349,279
875,635 -> 875,420
552,174 -> 552,635
10,93 -> 853,936
909,82 -> 909,926
511,743 -> 511,830
223,974 -> 223,124
829,543 -> 11,543
307,671 -> 206,570
126,72 -> 956,72
528,903 -> 528,223
644,524 -> 952,216
734,324 -> 734,105
225,558 -> 225,159
667,122 -> 667,64
582,93 -> 582,509
817,932 -> 727,932
898,18 -> 79,837
12,987 -> 986,13
426,79 -> 722,79
496,884 -> 906,884
953,183 -> 953,508
360,881 -> 975,881
765,862 -> 579,862
14,55 -> 14,560
454,333 -> 290,333
19,479 -> 91,551
696,41 -> 56,41
329,203 -> 812,203
498,559 -> 498,636
822,852 -> 614,852
410,370 -> 410,624
829,415 -> 805,415
775,980 -> 204,980
705,780 -> 116,191
49,30 -> 988,969
324,199 -> 554,199
727,572 -> 157,572
212,693 -> 93,693
886,105 -> 152,105
239,834 -> 958,115
623,920 -> 623,523
389,225 -> 106,508
443,426 -> 443,108
129,770 -> 858,41
906,559 -> 392,559
44,793 -> 774,793
693,275 -> 693,738
623,434 -> 184,873
774,623 -> 774,895
140,187 -> 140,238
247,503 -> 45,301
575,365 -> 950,365
101,120 -> 646,120
42,682 -> 649,75
749,767 -> 516,534
551,53 -> 73,531
15,26 -> 885,896
749,15 -> 235,529
548,169 -> 784,405
458,564 -> 962,564
663,873 -> 678,873
349,773 -> 349,927
777,180 -> 637,320
238,306 -> 844,912
927,818 -> 652,543
404,673 -> 952,125
750,297 -> 18,297
926,958 -> 926,669
767,843 -> 767,833
151,136 -> 234,219
927,789 -> 468,330
593,361 -> 593,447
48,14 -> 954,920
282,972 -> 790,972
537,446 -> 202,446
847,125 -> 357,615
667,609 -> 299,609
820,987 -> 359,987
342,889 -> 595,889
692,414 -> 239,414
916,935 -> 70,89
289,884 -> 289,790
264,562 -> 373,562
850,24 -> 126,748
877,159 -> 213,823
702,607 -> 702,454
432,883 -> 432,260
530,387 -> 229,387
783,39 -> 783,933
757,775 -> 757,81
416,376 -> 474,376
220,462 -> 220,824
438,317 -> 421,317
403,312 -> 866,312
902,923 -> 204,923
345,33 -> 819,33
376,521 -> 549,521
172,320 -> 129,277
25,975 -> 976,24
730,108 -> 465,373
607,468 -> 737,598
376,55 -> 672,55
807,113 -> 974,113
345,804 -> 695,454
687,921 -> 650,884
262,743 -> 262,753
889,734 -> 499,344
424,727 -> 909,242
100,957 -> 100,832
558,958 -> 376,958
422,473 -> 539,356
424,463 -> 158,463
329,543 -> 816,543
300,74 -> 362,136
620,691 -> 620,312
215,727 -> 360,582
692,116 -> 618,116
945,722 -> 945,560
851,83 -> 450,484
692,424 -> 254,862
160,214 -> 160,405
937,101 -> 854,184
989,14 -> 18,985
256,275 -> 828,847
797,748 -> 509,748
521,148 -> 422,148
85,549 -> 85,807
689,688 -> 443,442
750,664 -> 648,562
51,616 -> 51,54
925,272 -> 925,696
284,560 -> 369,560
509,685 -> 509,559
985,157 -> 273,869
570,765 -> 614,721
62,981 -> 985,58
289,496 -> 289,104
752,232 -> 692,292
82,948 -> 683,948
15,20 -> 984,989
252,950 -> 252,132
930,659 -> 614,659
552,449 -> 798,695
850,894 -> 342,386
412,465 -> 412,383
249,616 -> 351,718
759,289 -> 613,289
673,347 -> 673,842
749,493 -> 449,493
378,468 -> 378,674
914,924 -> 890,900
514,56 -> 606,56
855,233 -> 979,233
170,756 -> 170,961
450,601 -> 450,87
868,192 -> 125,935
702,137 -> 231,608
109,36 -> 632,36
511,472 -> 511,945
208,884 -> 923,169
831,66 -> 146,66
435,133 -> 884,133
900,418 -> 916,418
957,104 -> 127,104
608,892 -> 608,40
554,782 -> 55,782
305,260 -> 305,712
942,143 -> 226,859
823,778 -> 317,778
228,415 -> 228,445
313,505 -> 669,505
43,539 -> 43,187
14,84 -> 743,813
687,101 -> 277,101
549,977 -> 549,392
21,637 -> 214,637
950,961 -> 104,115
778,831 -> 958,831
214,765 -> 579,765
586,42 -> 89,42
505,950 -> 505,115
144,734 -> 144,813
11,349 -> 11,681
49,336 -> 99,386
560,187 -> 560,551
678,602 -> 761,519
131,515 -> 411,795
957,835 -> 957,106
948,852 -> 948,990
541,946 -> 541,405
355,147 -> 724,516
644,476 -> 625,476
789,818 -> 207,236
259,57 -> 431,57
441,375 -> 441,34
774,121 -> 882,13
655,397 -> 188,864
467,432 -> 235,200
268,121 -> 268,842
975,14 -> 11,978
124,904 -> 935,93
401,582 -> 420,582
170,700 -> 523,347
20,681 -> 20,174
420,939 -> 173,692
61,933 -> 956,38
686,458 -> 686,939
780,561 -> 305,86
792,644 -> 792,780
632,550 -> 938,550
441,252 -> 841,252
789,59 -> 789,418
981,11 -> 278,714
264,41 -> 264,186
870,833 -> 605,568
160,905 -> 160,783
385,191 -> 385,403
774,791 -> 69,86
409,967 -> 409,173
868,41 -> 868,235
536,497 -> 949,497
757,119 -> 156,720
563,706 -> 883,706
124,482 -> 14,482
353,655 -> 904,104
194,868 -> 194,649
810,736 -> 748,736
815,578 -> 50,578
531,131 -> 241,131
18,972 -> 977,13
761,747 -> 73,59
650,701 -> 930,701
470,237 -> 470,740
333,803 -> 954,182
644,667 -> 235,667
943,766 -> 299,766
985,876 -> 985,503
170,924 -> 467,924
249,19 -> 981,751
462,666 -> 462,651
404,228 -> 877,228
174,440 -> 174,847
910,596 -> 672,596
430,663 -> 734,663
711,294 -> 69,294
193,302 -> 257,302
959,20 -> 13,966
171,561 -> 171,953
704,986 -> 29,311
285,886 -> 285,260
945,872 -> 531,458
265,748 -> 478,748
26,537 -> 26,851
205,210 -> 917,922
590,488 -> 241,139
536,179 -> 247,179

2
2021/data/day6.expected Normal file
View file

@ -0,0 +1,2 @@
391888
1754597645339

1
2021/data/day6.input Normal file
View file

@ -0,0 +1 @@
5,1,1,4,1,1,4,1,1,1,1,1,1,1,1,1,1,1,4,2,1,1,1,3,5,1,1,1,5,4,1,1,1,2,2,1,1,1,2,1,1,1,2,5,2,1,2,2,3,1,1,1,1,1,1,1,1,5,1,1,4,1,1,1,5,4,1,1,3,3,2,1,1,1,5,1,1,4,1,1,5,1,1,5,1,2,3,1,5,1,3,2,1,3,1,1,4,1,1,1,1,2,1,2,1,1,2,1,1,1,4,4,1,5,1,1,3,5,1,1,5,1,4,1,1,1,1,1,1,1,1,1,2,2,3,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,5,1,1,1,1,4,1,1,1,1,4,1,1,1,1,3,1,2,1,2,1,3,1,3,4,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,4,1,1,2,2,1,2,4,1,1,3,1,1,1,5,1,3,1,1,1,5,5,1,1,1,1,2,3,4,1,1,1,1,1,1,1,1,1,1,1,1,5,1,4,3,1,1,1,2,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,3,3,1,2,2,1,4,1,5,1,5,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,4,3,1,1,4

View file

@ -1,3 +1,4 @@
#![warn(clippy::pedantic)]
use itertools::Itertools; use itertools::Itertools;
use std::io::{self, BufRead}; use std::io::{self, BufRead};
@ -18,7 +19,7 @@ fn main() {
count_increasing( count_increasing(
numbers numbers
.windows(3) .windows(3)
.map(|window| -> usize { window.iter().sum() }) .map(|window| window.iter().sum::<usize>())
) )
); );
} }

38
2021/day3/day3.py Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env python
import sys
from collections import Counter
def most_common(ns, pos):
c = Counter(n[pos] for n in ns)
num_zeros = c['0']
num_ones = c['1']
if num_ones >= num_zeros:
return '1'
else:
return '0'
def least_common(ns, pos):
return '0' if most_common(ns, pos) == '1' else '1'
def find_criteria(ns, criteria):
ns = ns
i = 0
while len(ns) > 1:
x = criteria(ns, i)
ns = [n for n in ns if n[i] == x]
i += 1
return ns[0]
if __name__ == '__main__':
lines = [line.strip() for line in sys.stdin.readlines()]
line_len = len(lines[0])
gamma = ''.join(most_common(lines, n) for n in range(line_len))
epsilon = ''.join(least_common(lines, n) for n in range(line_len))
print(int(gamma, 2) * int(epsilon, 2))
oxygen_rating = find_criteria(lines, most_common)
co2_rating = find_criteria(lines, least_common)
print(int(oxygen_rating, 2) * int(co2_rating, 2))

View file

@ -0,0 +1,8 @@
[package]
name = "day3_rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -0,0 +1,58 @@
#![warn(clippy::pedantic)]
use std::io::{stdin, BufRead};
fn find_rating(num_bits: usize, mut range: &[usize], keep_most_common_bit: bool) -> usize {
for idx in (0..num_bits).rev() {
if range.len() == 1 {
break;
}
let nth_bit = |x| x >> idx & 1;
let partition_point = range.iter().position(|&n| nth_bit(n) == 1).unwrap();
let center_bit = nth_bit(range[range.len() / 2]);
let keep_first_half = if keep_most_common_bit {
center_bit == 0
} else {
center_bit == 1
};
if keep_first_half {
range = &range[..partition_point];
} else {
range = &range[partition_point..];
}
}
range[0]
}
fn main() {
let lines: Vec<_> = stdin().lock().lines().map(Result::unwrap).collect();
let num_bits = lines[0].len();
let gamma: usize = (0..num_bits)
.map(|i| {
lines
.iter()
.filter(|line| line.chars().nth(i).unwrap() == '1')
.count()
})
.map(|n| if n > lines.len() / 2 { 1 } else { 0 })
.reduce(|accum, bit| accum << 1 | bit)
.unwrap();
let sigma = !gamma & ((1 << num_bits) - 1);
println!("{}", gamma * sigma);
let mut numbers: Vec<_> = lines
.iter()
.map(|n| usize::from_str_radix(n, 2).unwrap())
.collect();
numbers.sort_unstable();
let oxygen = find_rating(num_bits, &numbers, true);
let co2 = find_rating(num_bits, &numbers, false);
println!("{}", oxygen * co2);
}

41
2021/day4/day4.py Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env python
import time
import sys
def board_won(board):
for row in board:
if all(x is None for x in row):
return True
for i in range(len(board[0])):
if all(row[i] is None for row in board):
return True
return False
if __name__ == '__main__':
lines = [line.strip() for line in sys.stdin.readlines()]
draws = [int(n) for n in lines[0].split(',')]
boards = []
for i in range(2, len(lines), 6):
boards.append([[int(n) for n in line.split()] for line in lines[i:i+5]])
wins = []
for draw in draws:
for board_idx, board in enumerate(boards):
if board is None:
continue
for row in board:
try:
idx = row.index(draw)
row[idx] = None
except ValueError:
pass
if board_won(board):
wins.append(draw * sum(n for row in board for n in row if n is not None))
boards[board_idx] = None
print(wins[0])
print(wins[-1])

View file

@ -0,0 +1,9 @@
[package]
name = "day5_rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
vector2d = "2.2.0"

View file

@ -0,0 +1,114 @@
#![warn(clippy::pedantic)]
use std::{
convert::Infallible,
io::{stdin, BufRead},
str::FromStr,
};
use vector2d::Vector2D;
#[derive(Copy, Clone, Debug)]
struct Line {
start: Vector2D<usize>,
end: Vector2D<usize>,
}
impl Line {
pub fn is_straight(&self) -> bool {
self.start.x == self.end.x || self.start.y == self.end.y
}
pub fn expand(&self) -> impl Iterator<Item = Vector2D<usize>> {
LinePoints::new(self)
}
}
impl FromStr for Line {
type Err = Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Vec<_> = s.split(' ').collect();
let start: Vec<_> = parts[0].split(',').map(|n| n.parse().unwrap()).collect();
let end: Vec<_> = parts[2].split(',').map(|n| n.parse().unwrap()).collect();
Ok(Line {
start: Vector2D::new(start[0], start[1]),
end: Vector2D::new(end[0], end[1]),
})
}
}
struct LinePoints {
pos: Vector2D<isize>,
step: Vector2D<isize>,
points_left: usize,
}
impl LinePoints {
fn new(line: &Line) -> Self {
let start = line.start.as_isizes();
let end = line.end.as_isizes();
let delta = end - start;
let step = Vector2D::new(delta.x.signum(), delta.y.signum());
let len = usize::max(delta.x.unsigned_abs(), delta.y.unsigned_abs());
Self {
pos: start,
step,
points_left: len + 1,
}
}
}
impl Iterator for LinePoints {
type Item = Vector2D<usize>;
fn next(&mut self) -> Option<Self::Item> {
if self.points_left == 0 {
return None;
}
let current = self.pos;
self.pos += self.step;
self.points_left -= 1;
Some(current.as_usizes())
}
}
fn count_overlaps<'a>(it: impl IntoIterator<Item = &'a Line>) -> usize {
let points: Vec<(usize, usize)> = it
.into_iter()
.flat_map(Line::expand)
.map(Into::into)
.collect();
let (max_x, max_y) = points.iter().fold((0, 0), |(acc_x, acc_y), &(x, y)| {
(usize::max(acc_x, x), usize::max(acc_y, y))
});
let mut field = vec![vec![0_usize; max_y + 1]; max_x + 1];
let mut hits = 0;
for (x, y) in points {
let point = &mut field[x][y];
if *point == 1 {
hits += 1;
}
*point += 1;
}
hits
}
fn main() {
let lines: Vec<Line> = stdin()
.lock()
.lines()
.map(|s| s.unwrap().parse().unwrap())
.collect();
println!(
"{}",
count_overlaps(lines.iter().filter(|line| line.is_straight()))
);
println!("{}", count_overlaps(&lines));
}

20
2021/day6/day6.py Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python
import sys
import functools
@functools.cache
def spawns(days):
acc = days//7
days -= 9
acc += sum(spawns(days-x*7) for x in range(days//7))
return acc
if __name__ == '__main__':
inp = [int(i) for i in sys.stdin.readline().split(',')]
def do(days):
spawns.cache_clear()
return sum(1 + spawns(days + (6 - fish)) for fish in inp)
print(do(80))
print(do(256))