Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a17669107
|
||
|
|
127257c494
|
||
|
|
7b9a71f84c
|
||
|
|
669e2cfb2c
|
||
|
|
2274eca981
|
||
|
|
b1e4c4d634
|
||
|
|
4b3fc7eb73
|
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
aoc "go.sour.is/advent-of-code"
|
||||
@@ -62,7 +63,7 @@ func run(scan *bufio.Scanner) (*result, error) {
|
||||
func(i int, v int, counts [3]int) [3]int {
|
||||
counts[v]++
|
||||
return counts
|
||||
}, [3]int{}, maps.Values(memo)...)
|
||||
}, [3]int{}, slices.Values(maps.Values(memo)))
|
||||
|
||||
// fmt.Println(i, counts)
|
||||
i = 1_000_000_000 - (1_000_000_000-counts[0]-counts[1])%counts[2]
|
||||
|
||||
@@ -32,14 +32,14 @@ func run(scan *bufio.Scanner) (*result, error) {
|
||||
r.valuePT1 = aoc.Reduce(func(i int, t string, sum int) int {
|
||||
sum += hash(t)
|
||||
return sum
|
||||
}, 0, ops...)
|
||||
}, 0, slices.Values(ops))
|
||||
}
|
||||
|
||||
var boxen boxes
|
||||
|
||||
boxen = aoc.Reduce(func(i int, op string, b boxes) boxes {
|
||||
return b.Op(op)
|
||||
}, boxen, ops...)
|
||||
}, boxen, slices.Values(ops))
|
||||
|
||||
r.valuePT2 = boxen.Sum()
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3
|
||||
@@ -0,0 +1,1000 @@
|
||||
17633 15737
|
||||
79440 47531
|
||||
44767 73309
|
||||
86871 26386
|
||||
66575 90774
|
||||
31637 38259
|
||||
89855 50198
|
||||
81829 20253
|
||||
95071 98569
|
||||
34163 43719
|
||||
28696 84802
|
||||
10975 89855
|
||||
48232 15737
|
||||
14078 99983
|
||||
40882 73431
|
||||
75659 94769
|
||||
85341 13345
|
||||
92610 16338
|
||||
18043 59463
|
||||
60606 24540
|
||||
22376 46760
|
||||
14535 24785
|
||||
26022 94769
|
||||
90745 76304
|
||||
94386 84190
|
||||
22699 50602
|
||||
48716 38259
|
||||
93599 63674
|
||||
24797 57698
|
||||
89866 94029
|
||||
13841 87991
|
||||
12612 31743
|
||||
22889 53500
|
||||
84705 43272
|
||||
50982 26386
|
||||
19312 68554
|
||||
43985 36005
|
||||
23864 99058
|
||||
71953 45509
|
||||
58611 64279
|
||||
15949 98297
|
||||
89181 99781
|
||||
57095 54781
|
||||
19462 82924
|
||||
13989 32724
|
||||
74037 81607
|
||||
98414 34699
|
||||
17793 73309
|
||||
77332 64279
|
||||
17360 75855
|
||||
88430 38259
|
||||
59633 52523
|
||||
93603 31051
|
||||
93215 57119
|
||||
89750 48853
|
||||
73983 31051
|
||||
95163 35142
|
||||
50441 65929
|
||||
66767 72254
|
||||
96947 78965
|
||||
62870 50159
|
||||
46395 76148
|
||||
25246 21955
|
||||
39127 18070
|
||||
69589 72254
|
||||
87118 77505
|
||||
89577 11697
|
||||
64365 17982
|
||||
89417 90211
|
||||
38259 91050
|
||||
14458 32457
|
||||
42775 20442
|
||||
58228 72254
|
||||
87729 30434
|
||||
63480 17982
|
||||
90234 31051
|
||||
19242 94087
|
||||
77553 64344
|
||||
42962 27509
|
||||
20746 70689
|
||||
42003 14840
|
||||
24751 72254
|
||||
98825 66551
|
||||
35667 48627
|
||||
86088 43388
|
||||
87433 12947
|
||||
42556 73309
|
||||
77443 26386
|
||||
85947 66440
|
||||
26239 23875
|
||||
51904 10613
|
||||
45935 55396
|
||||
93900 79692
|
||||
94769 26138
|
||||
89944 29196
|
||||
16924 31743
|
||||
29441 72254
|
||||
31685 52714
|
||||
28455 38856
|
||||
82408 89991
|
||||
50492 79692
|
||||
48587 27909
|
||||
52190 51936
|
||||
14432 26239
|
||||
40296 90211
|
||||
87571 15975
|
||||
68554 82924
|
||||
60909 77747
|
||||
90581 50216
|
||||
17874 89227
|
||||
77699 84802
|
||||
52227 95383
|
||||
81281 38845
|
||||
74510 77249
|
||||
34913 52738
|
||||
17927 11147
|
||||
38246 67042
|
||||
95559 90562
|
||||
97142 94769
|
||||
17388 43583
|
||||
45933 73309
|
||||
61625 92202
|
||||
92202 60021
|
||||
32609 42173
|
||||
10121 15737
|
||||
42108 52145
|
||||
99781 88040
|
||||
71839 52086
|
||||
31215 12281
|
||||
23028 11321
|
||||
45513 36187
|
||||
44989 92435
|
||||
21042 26664
|
||||
41686 53092
|
||||
49396 13345
|
||||
87383 24542
|
||||
57374 94769
|
||||
92305 94769
|
||||
90956 73220
|
||||
59298 60825
|
||||
71833 61968
|
||||
39322 15153
|
||||
90211 98328
|
||||
78524 76232
|
||||
56222 48717
|
||||
88896 42647
|
||||
24989 84802
|
||||
15618 57610
|
||||
40750 15330
|
||||
57787 59202
|
||||
66076 64279
|
||||
27005 46356
|
||||
12299 27983
|
||||
99606 96968
|
||||
78648 88145
|
||||
90191 82924
|
||||
40731 26599
|
||||
28572 32457
|
||||
29036 39980
|
||||
12210 26664
|
||||
72284 11697
|
||||
76661 90364
|
||||
90125 24914
|
||||
42239 14455
|
||||
11589 61336
|
||||
33000 72254
|
||||
10758 31712
|
||||
10172 21525
|
||||
39561 91482
|
||||
47405 95316
|
||||
44894 83948
|
||||
46926 43967
|
||||
59896 87826
|
||||
85512 65546
|
||||
58641 79692
|
||||
83574 57878
|
||||
98203 84802
|
||||
43633 10581
|
||||
47564 69216
|
||||
87287 82731
|
||||
43747 13345
|
||||
91297 79692
|
||||
76432 18598
|
||||
75790 26386
|
||||
93818 96480
|
||||
31051 38259
|
||||
47511 64279
|
||||
97907 22026
|
||||
87367 90211
|
||||
59976 50541
|
||||
52149 99781
|
||||
17942 67693
|
||||
99139 69460
|
||||
66216 49858
|
||||
29264 38259
|
||||
82924 51350
|
||||
66027 25520
|
||||
82954 73309
|
||||
12290 67322
|
||||
20683 93568
|
||||
85750 13345
|
||||
54662 52685
|
||||
79346 31641
|
||||
76068 84568
|
||||
39015 79773
|
||||
30045 19435
|
||||
82962 25655
|
||||
20148 42108
|
||||
67813 29679
|
||||
65066 26239
|
||||
84222 63931
|
||||
13345 59242
|
||||
90893 48967
|
||||
51707 83112
|
||||
42399 15737
|
||||
40546 66000
|
||||
19343 92202
|
||||
95420 14200
|
||||
81543 55348
|
||||
28417 13345
|
||||
57947 91893
|
||||
76560 24540
|
||||
25531 23044
|
||||
60453 50868
|
||||
48959 38856
|
||||
66180 16455
|
||||
16907 83845
|
||||
79677 32420
|
||||
69680 92202
|
||||
65677 32375
|
||||
58869 79692
|
||||
49481 19672
|
||||
81530 26664
|
||||
30968 18603
|
||||
40003 36218
|
||||
70770 89227
|
||||
51169 17982
|
||||
39585 99781
|
||||
41887 90211
|
||||
98401 68715
|
||||
66079 60199
|
||||
79686 17982
|
||||
95976 34064
|
||||
62505 24540
|
||||
66440 31743
|
||||
66353 26239
|
||||
37729 66440
|
||||
78716 84802
|
||||
87428 62768
|
||||
52512 89855
|
||||
86117 84802
|
||||
54387 68022
|
||||
13759 78689
|
||||
40476 66769
|
||||
44961 19623
|
||||
99372 68799
|
||||
89090 79636
|
||||
61709 42060
|
||||
66586 11972
|
||||
68112 33028
|
||||
56457 31743
|
||||
58500 37748
|
||||
49835 52835
|
||||
69526 95383
|
||||
81736 84802
|
||||
72397 80320
|
||||
28792 44785
|
||||
67973 74969
|
||||
28140 79692
|
||||
99229 95383
|
||||
37502 67333
|
||||
21071 32457
|
||||
98028 82116
|
||||
13892 64667
|
||||
64351 19859
|
||||
39347 86071
|
||||
73309 94769
|
||||
25904 31051
|
||||
50933 28770
|
||||
81957 97102
|
||||
53641 15737
|
||||
88814 42916
|
||||
92575 26239
|
||||
62255 54132
|
||||
81785 72088
|
||||
75349 50602
|
||||
83203 89855
|
||||
98080 81605
|
||||
93942 31743
|
||||
97798 57279
|
||||
45256 73898
|
||||
51544 93706
|
||||
25195 88904
|
||||
68947 68366
|
||||
91830 68022
|
||||
91524 54353
|
||||
76708 31564
|
||||
90123 40095
|
||||
86890 21718
|
||||
98282 26239
|
||||
41961 42868
|
||||
11039 12856
|
||||
55505 73643
|
||||
56720 73309
|
||||
50589 35243
|
||||
18316 57600
|
||||
89706 26386
|
||||
77270 26934
|
||||
16280 31743
|
||||
38856 31317
|
||||
38306 72254
|
||||
22621 31743
|
||||
52085 35952
|
||||
25990 17841
|
||||
47713 46814
|
||||
50171 26239
|
||||
68656 30746
|
||||
16833 96013
|
||||
31650 59611
|
||||
38239 93728
|
||||
90966 22779
|
||||
20522 65624
|
||||
74289 88356
|
||||
30878 15020
|
||||
99343 90211
|
||||
46494 46080
|
||||
40055 98186
|
||||
62089 79296
|
||||
27261 11480
|
||||
14641 89227
|
||||
62672 51003
|
||||
43731 67153
|
||||
13641 93818
|
||||
81157 15737
|
||||
38752 93975
|
||||
22481 16596
|
||||
56161 26876
|
||||
11821 15737
|
||||
21702 42699
|
||||
95781 99704
|
||||
96637 61893
|
||||
52222 25556
|
||||
56805 32457
|
||||
43568 31051
|
||||
62828 15737
|
||||
19567 40953
|
||||
49559 25373
|
||||
55482 42108
|
||||
44986 95412
|
||||
53062 52392
|
||||
57314 26664
|
||||
37016 14626
|
||||
63361 92202
|
||||
68680 79692
|
||||
18476 89101
|
||||
20199 21632
|
||||
77823 89855
|
||||
69738 96520
|
||||
67170 40198
|
||||
79546 82924
|
||||
85110 88431
|
||||
54119 46332
|
||||
86781 92202
|
||||
90311 90211
|
||||
57902 82924
|
||||
54606 12067
|
||||
75696 90211
|
||||
31498 77415
|
||||
63061 47498
|
||||
20426 30513
|
||||
77880 79692
|
||||
80653 46725
|
||||
12847 77929
|
||||
67482 73832
|
||||
41457 22015
|
||||
96070 37125
|
||||
26083 87259
|
||||
15571 17982
|
||||
64763 81999
|
||||
69049 22033
|
||||
37215 73309
|
||||
68721 84808
|
||||
41483 43032
|
||||
19623 21237
|
||||
80415 94769
|
||||
40289 47860
|
||||
29800 15737
|
||||
51573 87470
|
||||
95147 93818
|
||||
49768 43274
|
||||
57896 47996
|
||||
11698 31743
|
||||
18534 93345
|
||||
33315 66184
|
||||
93295 26435
|
||||
13998 14286
|
||||
37866 42108
|
||||
27311 91778
|
||||
88630 50602
|
||||
61311 65732
|
||||
58088 54659
|
||||
39038 92202
|
||||
21263 32457
|
||||
68733 26239
|
||||
56327 26386
|
||||
10831 84802
|
||||
41475 14140
|
||||
65191 84802
|
||||
65689 10408
|
||||
99405 76417
|
||||
60130 26296
|
||||
62835 15737
|
||||
43765 25627
|
||||
37857 74612
|
||||
75626 26698
|
||||
82299 39722
|
||||
59124 44751
|
||||
11662 59626
|
||||
13403 38259
|
||||
84021 71058
|
||||
46515 31743
|
||||
19274 99781
|
||||
42981 66150
|
||||
81200 96138
|
||||
28115 52538
|
||||
66036 73617
|
||||
46632 44785
|
||||
44785 45999
|
||||
93611 94769
|
||||
58202 27856
|
||||
83448 31743
|
||||
47387 99781
|
||||
56227 19962
|
||||
10056 90211
|
||||
47436 42592
|
||||
25614 38259
|
||||
91347 94837
|
||||
93293 87462
|
||||
54018 13345
|
||||
93975 24540
|
||||
88534 28661
|
||||
55107 36119
|
||||
90676 30422
|
||||
74207 72254
|
||||
53544 11697
|
||||
82027 50515
|
||||
28952 93818
|
||||
24039 73309
|
||||
51681 59383
|
||||
84784 33827
|
||||
57727 38856
|
||||
17375 79692
|
||||
84334 75729
|
||||
85913 61227
|
||||
34190 70516
|
||||
88405 93909
|
||||
57014 89855
|
||||
49572 51212
|
||||
96919 57120
|
||||
57074 84802
|
||||
97433 94600
|
||||
39316 19546
|
||||
23267 73309
|
||||
49617 62475
|
||||
45398 49944
|
||||
93789 84802
|
||||
80870 79692
|
||||
66592 89412
|
||||
84914 21538
|
||||
15737 58959
|
||||
85633 17470
|
||||
24299 89227
|
||||
50996 28076
|
||||
59760 37410
|
||||
19853 36303
|
||||
87172 63500
|
||||
73167 26239
|
||||
69533 58203
|
||||
10294 47085
|
||||
10068 84802
|
||||
71528 59133
|
||||
90074 48734
|
||||
85177 13345
|
||||
39240 19623
|
||||
46901 31230
|
||||
31573 14744
|
||||
40287 76713
|
||||
52063 31743
|
||||
15665 92202
|
||||
55652 57799
|
||||
94618 43492
|
||||
35516 17699
|
||||
99836 97684
|
||||
12266 93653
|
||||
49382 94769
|
||||
58480 27713
|
||||
30160 95383
|
||||
15895 82924
|
||||
99570 35771
|
||||
86138 29452
|
||||
50602 15240
|
||||
65863 72856
|
||||
14014 17313
|
||||
23202 73309
|
||||
52442 99781
|
||||
98402 62424
|
||||
99960 93818
|
||||
30587 37482
|
||||
27344 71566
|
||||
14901 18107
|
||||
50646 87619
|
||||
39894 82924
|
||||
76102 79692
|
||||
93553 41109
|
||||
95383 19459
|
||||
43523 34173
|
||||
93147 15737
|
||||
52736 86381
|
||||
73737 38856
|
||||
74670 89855
|
||||
70375 44671
|
||||
35660 27596
|
||||
68216 72680
|
||||
87067 46274
|
||||
74103 75792
|
||||
95109 17982
|
||||
17982 92202
|
||||
81693 14959
|
||||
72925 13345
|
||||
79007 26239
|
||||
56890 75332
|
||||
43163 94330
|
||||
89721 89227
|
||||
98999 88213
|
||||
24385 71775
|
||||
31463 68554
|
||||
86271 72254
|
||||
76927 43416
|
||||
82914 88520
|
||||
10672 42227
|
||||
37107 72254
|
||||
53415 65905
|
||||
57507 32457
|
||||
61956 80596
|
||||
53426 42108
|
||||
24147 73170
|
||||
42957 89855
|
||||
82795 66358
|
||||
36784 93211
|
||||
33334 18704
|
||||
81024 79692
|
||||
50757 87305
|
||||
11023 19777
|
||||
56827 91998
|
||||
63122 72254
|
||||
22187 93663
|
||||
45790 24392
|
||||
45455 25374
|
||||
18321 90211
|
||||
50449 42108
|
||||
88021 45580
|
||||
49799 13345
|
||||
87225 94769
|
||||
97435 26386
|
||||
83558 87182
|
||||
38550 95383
|
||||
33452 13345
|
||||
56025 17982
|
||||
67783 93390
|
||||
84187 48977
|
||||
39395 89716
|
||||
68418 38259
|
||||
52548 89161
|
||||
28163 72254
|
||||
84823 89227
|
||||
31206 15482
|
||||
64705 44785
|
||||
58401 31743
|
||||
95618 38856
|
||||
91709 93818
|
||||
48005 92202
|
||||
76020 82924
|
||||
23833 93782
|
||||
52831 50653
|
||||
85010 31743
|
||||
10664 99781
|
||||
22411 13783
|
||||
43979 31051
|
||||
61257 57691
|
||||
61520 15737
|
||||
48746 88134
|
||||
14279 44785
|
||||
47898 89855
|
||||
93422 88779
|
||||
68022 92202
|
||||
14459 96167
|
||||
89227 40096
|
||||
20824 33236
|
||||
75208 79692
|
||||
49845 41520
|
||||
51562 87703
|
||||
93302 64917
|
||||
92836 95935
|
||||
49142 35882
|
||||
50653 24538
|
||||
70201 17982
|
||||
13156 26664
|
||||
72511 68022
|
||||
25934 38856
|
||||
91338 47911
|
||||
75287 41621
|
||||
15292 17284
|
||||
61020 24851
|
||||
24871 93818
|
||||
69502 32804
|
||||
22107 32457
|
||||
11069 17982
|
||||
90501 32457
|
||||
79735 33307
|
||||
22407 40613
|
||||
56638 73309
|
||||
43995 97846
|
||||
24346 10698
|
||||
19332 64254
|
||||
98053 96741
|
||||
64279 95856
|
||||
35846 80488
|
||||
87249 15737
|
||||
26693 91433
|
||||
23953 37660
|
||||
36613 18796
|
||||
68547 42108
|
||||
29801 84802
|
||||
95876 20755
|
||||
96850 26239
|
||||
69173 21661
|
||||
15143 95829
|
||||
88911 12796
|
||||
85370 24540
|
||||
37936 55116
|
||||
27252 62202
|
||||
52765 68022
|
||||
85421 74199
|
||||
29524 26239
|
||||
50768 66440
|
||||
43558 86684
|
||||
51533 89797
|
||||
52414 88190
|
||||
69357 10930
|
||||
37499 82866
|
||||
51109 73091
|
||||
56299 68022
|
||||
35287 90211
|
||||
24335 31051
|
||||
66593 96407
|
||||
34510 24540
|
||||
59870 24540
|
||||
95114 93204
|
||||
25535 45844
|
||||
77617 36433
|
||||
90219 94315
|
||||
79862 38856
|
||||
23936 94769
|
||||
97001 31743
|
||||
80515 77665
|
||||
79565 73309
|
||||
26333 64279
|
||||
75467 90211
|
||||
76518 59553
|
||||
43602 20354
|
||||
36813 99477
|
||||
43716 27733
|
||||
65228 92202
|
||||
23719 94557
|
||||
27276 37673
|
||||
79341 13382
|
||||
92730 64279
|
||||
13327 26664
|
||||
74695 71838
|
||||
26891 51076
|
||||
27088 98880
|
||||
69958 38856
|
||||
91806 17982
|
||||
85215 82201
|
||||
87804 97407
|
||||
87074 38259
|
||||
91912 67024
|
||||
88017 73309
|
||||
37176 26386
|
||||
86262 52774
|
||||
79370 72254
|
||||
59531 72254
|
||||
87454 61531
|
||||
56438 90211
|
||||
69511 28232
|
||||
56851 38259
|
||||
65430 80706
|
||||
36077 17982
|
||||
25960 94769
|
||||
71485 38856
|
||||
54398 90211
|
||||
28265 28278
|
||||
78120 87123
|
||||
59446 34818
|
||||
26386 89227
|
||||
83452 48947
|
||||
37184 37978
|
||||
61882 68022
|
||||
85743 83130
|
||||
58108 93975
|
||||
88676 91673
|
||||
56709 31769
|
||||
60790 80223
|
||||
13675 30664
|
||||
26508 38856
|
||||
86384 45096
|
||||
11697 51693
|
||||
18506 84802
|
||||
64140 26386
|
||||
72254 73309
|
||||
32457 31743
|
||||
47880 57178
|
||||
28362 66440
|
||||
41762 94769
|
||||
52860 13501
|
||||
76072 37914
|
||||
28664 30385
|
||||
38694 83674
|
||||
77076 73416
|
||||
52304 15737
|
||||
48805 97201
|
||||
79691 84802
|
||||
60446 31743
|
||||
50527 13345
|
||||
57332 73119
|
||||
91969 69182
|
||||
24540 42108
|
||||
52000 10568
|
||||
60350 85617
|
||||
65954 75315
|
||||
77087 26664
|
||||
11673 21083
|
||||
86822 31308
|
||||
46369 94769
|
||||
72162 80387
|
||||
78984 15737
|
||||
86619 94893
|
||||
97668 19111
|
||||
98988 92336
|
||||
82635 29846
|
||||
13455 94769
|
||||
58975 80353
|
||||
25865 16923
|
||||
53039 10038
|
||||
30768 15737
|
||||
12014 14617
|
||||
46545 19623
|
||||
25611 38259
|
||||
68704 97611
|
||||
19940 47269
|
||||
86483 63673
|
||||
57437 51287
|
||||
61703 26386
|
||||
48018 51102
|
||||
67563 66460
|
||||
40899 62325
|
||||
39500 34475
|
||||
54669 11697
|
||||
58288 88743
|
||||
74372 50602
|
||||
78876 81743
|
||||
44932 34577
|
||||
63464 81249
|
||||
83883 68022
|
||||
52588 82924
|
||||
32785 67603
|
||||
50300 78946
|
||||
43503 50602
|
||||
64904 84802
|
||||
76135 68022
|
||||
35611 93677
|
||||
64841 34132
|
||||
10588 30349
|
||||
63814 48233
|
||||
19013 17210
|
||||
80561 64619
|
||||
88208 26239
|
||||
10576 10445
|
||||
99430 92202
|
||||
38695 90117
|
||||
32677 30805
|
||||
28960 72254
|
||||
76150 37024
|
||||
27997 66440
|
||||
25216 38259
|
||||
75079 95383
|
||||
19640 32457
|
||||
87142 24540
|
||||
29691 73136
|
||||
43608 60367
|
||||
37613 29457
|
||||
11187 86291
|
||||
14208 97616
|
||||
85169 89855
|
||||
12976 24540
|
||||
64222 52066
|
||||
10454 14324
|
||||
26231 19580
|
||||
94650 15737
|
||||
58941 89855
|
||||
79692 27316
|
||||
54692 10285
|
||||
63161 69466
|
||||
89688 14267
|
||||
88077 93568
|
||||
81434 41368
|
||||
30007 84802
|
||||
93568 72254
|
||||
38883 73016
|
||||
69231 94769
|
||||
14633 72555
|
||||
22196 79692
|
||||
48676 84802
|
||||
87546 84802
|
||||
87523 24540
|
||||
95107 73309
|
||||
79211 15737
|
||||
55870 89227
|
||||
10953 36166
|
||||
11083 73309
|
||||
21863 36153
|
||||
38429 62600
|
||||
61106 92358
|
||||
97986 93975
|
||||
88704 38856
|
||||
93825 66535
|
||||
29839 40913
|
||||
24546 21464
|
||||
74178 15737
|
||||
42883 94769
|
||||
40996 38622
|
||||
42992 26664
|
||||
71684 42730
|
||||
57251 23426
|
||||
26664 31743
|
||||
68948 73753
|
||||
97206 68022
|
||||
57843 33400
|
||||
49113 13345
|
||||
60920 50511
|
||||
22678 89227
|
||||
72961 78397
|
||||
19802 38490
|
||||
86087 90211
|
||||
89652 66440
|
||||
49821 24540
|
||||
50537 79692
|
||||
73536 24540
|
||||
53929 98400
|
||||
60918 79692
|
||||
99061 49678
|
||||
37062 38238
|
||||
20934 72875
|
||||
67200 34807
|
||||
71415 94769
|
||||
99026 96883
|
||||
31743 14721
|
||||
59957 93818
|
||||
68759 76158
|
||||
41938 17982
|
||||
97993 69305
|
||||
80420 85851
|
||||
46816 93742
|
||||
28271 71400
|
||||
87923 32457
|
||||
67736 36498
|
||||
47677 92202
|
||||
56483 84724
|
||||
90236 79692
|
||||
64649 86922
|
||||
55425 46497
|
||||
12465 17982
|
||||
20096 82924
|
||||
60707 96546
|
||||
60329 73309
|
||||
17905 31743
|
||||
11135 17982
|
||||
29543 94769
|
||||
86447 79692
|
||||
77740 97091
|
||||
94482 84802
|
||||
93699 69588
|
||||
26097 13450
|
||||
98119 79692
|
||||
85496 14796
|
||||
86244 73309
|
||||
96663 59923
|
||||
15846 82924
|
||||
85935 72254
|
||||
27121 75478
|
||||
85411 84131
|
||||
30273 32457
|
||||
20039 82924
|
||||
78703 20706
|
||||
41844 64465
|
||||
68394 44785
|
||||
23329 90139
|
||||
58675 96125
|
||||
71413 93818
|
||||
73282 14167
|
||||
50904 89227
|
||||
85583 65246
|
||||
20025 17289
|
||||
47996 18160
|
||||
29785 31743
|
||||
95739 47118
|
||||
79616 92202
|
||||
88013 76315
|
||||
58837 91798
|
||||
78955 92642
|
||||
70336 26239
|
||||
24170 33987
|
||||
78256 24257
|
||||
10398 26386
|
||||
46571 93031
|
||||
93997 79692
|
||||
10668 45223
|
||||
86866 90211
|
||||
49014 53649
|
||||
69991 92202
|
||||
36977 90623
|
||||
92324 79031
|
||||
95872 13345
|
||||
84633 26386
|
||||
30462 24540
|
||||
32209 85790
|
||||
45036 80196
|
||||
17978 68976
|
||||
87590 50253
|
||||
84802 72481
|
||||
39492 68554
|
||||
35134 63205
|
||||
26840 17894
|
||||
75937 10487
|
||||
20865 70581
|
||||
22548 26386
|
||||
73301 56010
|
||||
55824 85167
|
||||
33501 38259
|
||||
97678 30745
|
||||
89755 41648
|
||||
59158 81505
|
||||
51201 66440
|
||||
31408 92202
|
||||
91451 90800
|
||||
70921 29799
|
||||
19367 13325
|
||||
77381 31051
|
||||
91572 89049
|
||||
77233 26502
|
||||
86139 70861
|
||||
60708 35871
|
||||
78193 26239
|
||||
24930 31852
|
||||
14024 82528
|
||||
64480 82924
|
||||
15775 26239
|
||||
75694 94769
|
||||
85608 73391
|
||||
81409 19623
|
||||
57211 26386
|
||||
94296 59256
|
||||
79582 21822
|
||||
59998 38856
|
||||
68629 13345
|
||||
17800 26239
|
||||
37775 44785
|
||||
70250 28657
|
||||
30006 39357
|
||||
80597 35930
|
||||
22013 93975
|
||||
78422 26239
|
||||
38548 24540
|
||||
86266 72254
|
||||
97848 26386
|
||||
84347 56506
|
||||
81988 28292
|
||||
17114 26660
|
||||
11319 73380
|
||||
41857 13345
|
||||
59624 18015
|
||||
75476 33080
|
||||
19083 13949
|
||||
58992 58123
|
||||
60891 32063
|
||||
30704 28458
|
||||
81706 98995
|
||||
65022 87326
|
||||
80970 46974
|
||||
78758 79469
|
||||
+58
-2
@@ -4,6 +4,9 @@ import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"iter"
|
||||
"slices"
|
||||
"sort"
|
||||
|
||||
aoc "go.sour.is/advent-of-code"
|
||||
)
|
||||
@@ -20,11 +23,64 @@ type result struct {
|
||||
func (r result) String() string { return fmt.Sprintf("%#v", r) }
|
||||
|
||||
func run(scan *bufio.Scanner) (*result, error) {
|
||||
var (
|
||||
left []int
|
||||
right []int
|
||||
)
|
||||
|
||||
for scan.Scan() {
|
||||
_ = scan.Text()
|
||||
txt := scan.Text()
|
||||
|
||||
var l, r int
|
||||
_, err := fmt.Sscanf(txt, "%d %d", &l, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
left = append(left, l)
|
||||
right = append(right, r)
|
||||
}
|
||||
|
||||
return &result{}, nil
|
||||
sort.Ints(left)
|
||||
sort.Ints(right)
|
||||
|
||||
result := &result{}
|
||||
|
||||
result.valuePT1 = aoc.Reduce(func(i int, z pair[int, int], sum int) int {
|
||||
return sum + aoc.ABS(z.L-z.R)
|
||||
}, 0, zip(slices.Values(left), slices.Values(right)))
|
||||
|
||||
rmap := aoc.Reduce(func(i int, z int, m map[int]int) map[int]int {
|
||||
m[z]++
|
||||
return m
|
||||
}, make(map[int]int), slices.Values(right))
|
||||
|
||||
for _, v := range left {
|
||||
if r, ok := rmap[v]; ok {
|
||||
result.valuePT2 += v*r
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
type pair[L, R any] struct {
|
||||
L L
|
||||
R R
|
||||
}
|
||||
|
||||
func zip[L, R any](l iter.Seq[L], r iter.Seq[R]) iter.Seq[pair[L,R]] {
|
||||
return func(yield func(pair[L, R]) bool) {
|
||||
pullR, stop := iter.Pull(r)
|
||||
defer stop()
|
||||
|
||||
for l := range l {
|
||||
r, _ := pullR()
|
||||
|
||||
if !yield(pair[L, R]{L: l, R: r}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ func TestExample(t *testing.T) {
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.Equal(result.valuePT1, 0)
|
||||
is.Equal(result.valuePT2, 0)
|
||||
is.Equal(result.valuePT1, 11)
|
||||
is.Equal(result.valuePT2, 31)
|
||||
}
|
||||
|
||||
func TestSolution(t *testing.T) {
|
||||
@@ -36,6 +36,6 @@ func TestSolution(t *testing.T) {
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.Equal(result.valuePT1, 0)
|
||||
is.Equal(result.valuePT2, 0)
|
||||
is.Equal(result.valuePT1, 2756096)
|
||||
is.Equal(result.valuePT2, 23117829)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9
|
||||
@@ -0,0 +1,1000 @@
|
||||
40 42 44 47 49 50 48
|
||||
65 67 70 71 72 75 75
|
||||
74 76 78 81 83 85 87 91
|
||||
73 76 79 81 82 85 86 91
|
||||
64 67 69 70 68 71 72
|
||||
76 78 77 79 82 80
|
||||
12 13 12 13 13
|
||||
57 59 61 64 65 62 66
|
||||
14 16 18 19 21 24 22 27
|
||||
36 37 37 38 39
|
||||
1 3 5 5 4
|
||||
72 73 76 76 78 78
|
||||
36 39 40 40 43 45 49
|
||||
24 26 26 29 31 37
|
||||
16 17 18 22 23 24 26 27
|
||||
56 57 61 63 66 65
|
||||
52 53 57 58 60 60
|
||||
40 43 47 49 53
|
||||
3 4 7 11 13 15 22
|
||||
84 87 92 93 95
|
||||
63 66 69 72 74 79 81 80
|
||||
43 45 47 52 54 57 57
|
||||
51 53 54 59 62 66
|
||||
19 20 25 28 31 32 33 38
|
||||
76 74 77 79 82 83 85 88
|
||||
22 20 22 25 28 29 26
|
||||
33 31 34 37 38 40 40
|
||||
24 21 22 24 25 26 30
|
||||
81 80 81 83 85 87 89 96
|
||||
33 31 32 35 37 38 36 38
|
||||
37 34 33 35 34
|
||||
62 61 63 66 68 67 67
|
||||
12 9 6 9 10 11 12 16
|
||||
32 29 26 27 30 32 34 40
|
||||
83 81 84 84 85
|
||||
97 96 96 98 97
|
||||
32 29 29 32 34 37 37
|
||||
87 85 87 90 91 91 95
|
||||
90 88 91 91 98
|
||||
67 66 70 72 73
|
||||
24 21 24 28 30 32 29
|
||||
6 3 7 9 9
|
||||
67 66 70 72 76
|
||||
43 40 41 42 46 48 55
|
||||
59 58 61 64 67 72 75 77
|
||||
84 83 89 92 94 92
|
||||
56 55 57 62 64 64
|
||||
11 8 9 12 17 19 20 24
|
||||
22 19 21 28 34
|
||||
52 52 53 56 58 59
|
||||
16 16 17 19 21 23 20
|
||||
86 86 88 91 92 95 95
|
||||
22 22 23 25 26 28 32
|
||||
72 72 75 78 84
|
||||
89 89 87 88 90
|
||||
89 89 88 89 87
|
||||
58 58 61 63 64 62 62
|
||||
75 75 76 77 79 81 79 83
|
||||
36 36 39 42 44 41 42 48
|
||||
76 76 78 79 79 80 82
|
||||
22 22 25 26 29 32 32 29
|
||||
31 31 31 34 37 40 42 42
|
||||
58 58 60 61 64 67 67 71
|
||||
2 2 4 4 10
|
||||
51 51 53 56 60 61 64
|
||||
61 61 64 68 65
|
||||
24 24 27 31 33 33
|
||||
70 70 71 74 78 82
|
||||
61 61 65 66 68 70 77
|
||||
44 44 46 48 54 56
|
||||
7 7 10 12 17 20 19
|
||||
23 23 25 32 33 33
|
||||
56 56 59 62 69 72 76
|
||||
31 31 34 35 37 43 48
|
||||
29 33 36 37 40 42 45 47
|
||||
10 14 17 18 21 24 27 25
|
||||
52 56 57 60 61 62 62
|
||||
72 76 79 80 83 84 85 89
|
||||
52 56 57 60 63 64 70
|
||||
23 27 24 26 27
|
||||
28 32 33 35 36 37 36 35
|
||||
7 11 13 11 14 17 17
|
||||
42 46 44 45 46 49 50 54
|
||||
35 39 37 39 42 43 45 50
|
||||
43 47 49 52 53 53 55
|
||||
79 83 83 85 86 87 85
|
||||
8 12 13 15 18 20 20 20
|
||||
67 71 72 73 73 77
|
||||
28 32 33 33 39
|
||||
48 52 56 58 59 61
|
||||
28 32 34 35 37 41 39
|
||||
25 29 33 36 39 39
|
||||
14 18 20 24 26 27 28 32
|
||||
59 63 66 69 73 78
|
||||
36 40 46 47 50 52
|
||||
15 19 26 28 29 28
|
||||
29 33 40 41 41
|
||||
52 56 57 58 65 67 71
|
||||
33 37 44 47 50 52 54 61
|
||||
21 26 27 29 30 33 36
|
||||
78 84 85 88 86
|
||||
50 55 57 59 60 60
|
||||
60 67 70 71 74 76 80
|
||||
59 64 66 67 68 74
|
||||
39 44 47 49 52 49 51
|
||||
3 10 11 13 15 16 14 11
|
||||
41 46 49 47 47
|
||||
74 80 77 78 82
|
||||
71 76 75 77 79 84
|
||||
45 50 50 52 53 55 58
|
||||
72 78 78 79 81 82 83 81
|
||||
7 13 16 17 17 17
|
||||
28 34 37 37 38 42
|
||||
54 59 61 61 64 67 74
|
||||
66 71 73 74 78 81
|
||||
27 34 38 41 43 46 48 46
|
||||
23 29 31 33 37 37
|
||||
27 33 36 38 42 44 47 51
|
||||
29 36 38 42 45 46 52
|
||||
55 60 61 68 70 73 76 77
|
||||
73 78 80 85 86 84
|
||||
72 79 81 83 90 92 93 93
|
||||
11 18 19 20 27 30 34
|
||||
66 73 75 82 88
|
||||
63 61 59 56 58
|
||||
83 80 78 77 77
|
||||
37 34 32 30 29 25
|
||||
78 77 75 72 69 67 61
|
||||
45 42 44 41 40
|
||||
6 5 6 5 7
|
||||
51 48 50 48 48
|
||||
84 83 81 80 79 80 77 73
|
||||
83 82 85 82 80 74
|
||||
57 56 56 55 54 52 51
|
||||
52 49 49 48 46 44 42 44
|
||||
8 7 7 6 6
|
||||
51 49 49 48 44
|
||||
72 70 68 65 65 58
|
||||
71 69 65 62 60 58
|
||||
72 69 65 63 60 63
|
||||
50 47 44 41 40 37 33 33
|
||||
62 60 56 55 51
|
||||
67 66 64 60 57 55 52 47
|
||||
99 96 90 88 87 85
|
||||
45 42 36 34 33 32 34
|
||||
73 70 68 66 64 61 56 56
|
||||
72 70 67 60 59 55
|
||||
21 20 13 12 10 4
|
||||
31 32 29 26 23
|
||||
53 56 55 53 54
|
||||
93 95 93 92 91 91
|
||||
51 53 52 51 49 45
|
||||
53 56 53 52 51 45
|
||||
6 7 4 5 4
|
||||
37 38 35 38 36 39
|
||||
71 73 75 74 73 72 71 71
|
||||
38 41 39 42 38
|
||||
20 23 21 18 19 12
|
||||
29 30 27 25 25 23 21 19
|
||||
5 7 7 4 1 4
|
||||
27 28 25 25 24 23 22 22
|
||||
84 87 87 84 80
|
||||
88 89 87 87 85 80
|
||||
54 55 54 50 48
|
||||
52 53 49 47 44 46
|
||||
55 57 56 54 50 48 48
|
||||
55 57 56 54 50 49 45
|
||||
41 43 42 40 37 36 32 27
|
||||
50 52 51 50 45 43 42 39
|
||||
38 40 38 31 30 32
|
||||
67 69 67 64 62 57 57
|
||||
81 83 80 78 73 69
|
||||
51 53 52 51 50 44 42 37
|
||||
65 65 63 61 59 56 55 54
|
||||
75 75 72 71 70 73
|
||||
44 44 42 41 39 38 37 37
|
||||
17 17 14 12 9 6 2
|
||||
61 61 59 56 53 46
|
||||
81 81 83 82 79
|
||||
88 88 86 84 87 85 86
|
||||
49 49 46 45 43 45 45
|
||||
97 97 95 98 96 92
|
||||
38 38 37 39 36 33 31 26
|
||||
60 60 60 57 56 54 53 50
|
||||
23 23 20 20 18 16 14 16
|
||||
96 96 96 93 93
|
||||
48 48 45 45 41
|
||||
69 69 66 65 65 63 58
|
||||
99 99 95 94 93 90 89
|
||||
8 8 5 1 2
|
||||
87 87 86 82 80 79 79
|
||||
32 32 31 28 24 21 18 14
|
||||
45 45 42 40 37 35 31 24
|
||||
63 63 56 55 53 52
|
||||
78 78 76 75 73 66 63 66
|
||||
67 67 62 59 59
|
||||
90 90 88 83 81 77
|
||||
58 58 57 56 55 54 49 42
|
||||
21 17 16 15 12 10 7 5
|
||||
33 29 28 25 23 21 24
|
||||
81 77 74 72 70 70
|
||||
36 32 31 28 26 23 19
|
||||
46 42 41 38 35 33 27
|
||||
66 62 61 63 60 59
|
||||
66 62 63 62 60 62
|
||||
76 72 69 71 69 66 66
|
||||
66 62 65 62 59 57 54 50
|
||||
48 44 43 45 42 36
|
||||
36 32 32 30 29
|
||||
74 70 68 68 65 68
|
||||
22 18 16 14 12 10 10 10
|
||||
67 63 63 60 57 56 52
|
||||
85 81 79 79 78 75 70
|
||||
49 45 44 41 37 34 32
|
||||
22 18 15 13 9 7 5 7
|
||||
45 41 37 35 35
|
||||
65 61 57 55 53 52 50 46
|
||||
82 78 77 76 72 67
|
||||
92 88 85 82 75 73 71 68
|
||||
67 63 61 55 53 51 54
|
||||
73 69 66 65 63 62 55 55
|
||||
82 78 73 72 71 67
|
||||
68 64 57 54 52 50 43
|
||||
84 78 76 75 72 70 69
|
||||
89 83 80 78 77 78
|
||||
83 76 73 70 68 68
|
||||
40 35 34 33 29
|
||||
61 56 55 52 51 46
|
||||
97 91 94 93 90 88
|
||||
97 90 88 91 88 86 89
|
||||
22 16 18 17 16 14 14
|
||||
42 37 36 39 38 36 33 29
|
||||
57 51 54 53 50 44
|
||||
89 83 81 79 79 78
|
||||
69 64 64 61 63
|
||||
22 15 12 10 10 8 5 5
|
||||
16 11 8 6 5 5 1
|
||||
29 24 23 23 21 19 16 11
|
||||
72 66 62 59 57 55
|
||||
83 76 72 69 66 65 62 65
|
||||
30 25 23 19 16 15 15
|
||||
52 47 43 41 38 34
|
||||
54 48 47 45 41 38 35 29
|
||||
61 54 53 52 47 46
|
||||
91 85 83 78 80
|
||||
25 19 18 13 11 11
|
||||
67 60 57 50 49 45
|
||||
55 48 45 40 37 35 28
|
||||
3 6 9 12 15 18 19 16
|
||||
53 55 56 58 59 59
|
||||
43 45 47 49 52 56
|
||||
11 12 15 18 24
|
||||
49 51 50 53 55 58
|
||||
21 24 27 28 30 29 27
|
||||
29 30 32 35 33 35 35
|
||||
2 5 4 6 10
|
||||
37 40 39 40 41 48
|
||||
60 63 66 68 71 71 73
|
||||
21 24 26 26 29 32 31
|
||||
7 8 8 9 12 13 13
|
||||
70 73 75 75 79
|
||||
22 23 24 24 25 27 29 34
|
||||
34 36 37 38 42 44
|
||||
70 71 72 75 77 81 79
|
||||
1 4 7 8 9 13 13
|
||||
64 66 69 73 75 77 80 84
|
||||
77 80 82 86 87 90 96
|
||||
59 60 61 67 70
|
||||
78 79 85 87 88 89 90 88
|
||||
8 11 13 19 21 22 22
|
||||
20 23 28 31 32 36
|
||||
22 24 30 32 39
|
||||
79 77 80 83 85 88
|
||||
28 27 28 29 27
|
||||
30 27 30 33 35 36 36
|
||||
61 60 63 66 70
|
||||
29 26 29 30 32 35 36 41
|
||||
76 73 72 73 76 78 81 83
|
||||
8 7 10 11 8 11 10
|
||||
11 10 12 13 16 17 14 14
|
||||
72 70 73 70 72 74 78
|
||||
57 54 57 56 59 60 65
|
||||
44 41 41 43 46
|
||||
28 27 27 28 30 27
|
||||
74 72 73 73 76 78 78
|
||||
21 18 18 21 23 25 29
|
||||
75 73 75 76 78 78 81 87
|
||||
73 72 76 78 81 84 87
|
||||
76 73 74 78 80 81 78
|
||||
68 67 71 72 72
|
||||
88 85 89 91 95
|
||||
26 23 25 28 32 33 36 41
|
||||
45 42 47 50 52 53
|
||||
81 80 85 86 83
|
||||
67 66 69 76 76
|
||||
43 42 44 51 53 56 60
|
||||
6 5 12 15 21
|
||||
49 49 50 51 53 55
|
||||
67 67 68 70 72 75 74
|
||||
1 1 4 5 6 9 9
|
||||
12 12 13 16 20
|
||||
44 44 45 46 47 53
|
||||
90 90 88 89 91 94 97
|
||||
77 77 74 76 77 76
|
||||
36 36 34 36 36
|
||||
46 46 48 50 49 53
|
||||
57 57 54 57 60 67
|
||||
30 30 31 31 34 36 37
|
||||
14 14 15 17 18 18 17
|
||||
51 51 52 52 52
|
||||
34 34 34 35 39
|
||||
5 5 7 7 13
|
||||
65 65 69 71 73
|
||||
17 17 21 23 20
|
||||
64 64 65 67 68 72 73 73
|
||||
46 46 48 49 53 57
|
||||
47 47 51 52 53 59
|
||||
64 64 69 71 72 75 77
|
||||
78 78 80 85 87 84
|
||||
10 10 11 12 19 20 20
|
||||
17 17 23 25 29
|
||||
48 48 51 56 63
|
||||
65 69 71 74 76 78
|
||||
31 35 36 39 40 42 43 40
|
||||
67 71 73 76 78 81 81
|
||||
62 66 67 68 69 72 74 78
|
||||
3 7 9 12 15 18 24
|
||||
44 48 46 48 49
|
||||
9 13 12 15 18 21 19
|
||||
56 60 61 64 66 64 64
|
||||
2 6 8 5 8 11 12 16
|
||||
78 82 84 81 83 90
|
||||
57 61 63 65 65 66
|
||||
53 57 57 60 58
|
||||
85 89 89 91 91
|
||||
45 49 52 52 53 57
|
||||
50 54 57 59 59 60 65
|
||||
14 18 22 24 27
|
||||
59 63 67 69 71 70
|
||||
7 11 12 16 16
|
||||
71 75 79 81 85
|
||||
25 29 33 36 39 44
|
||||
69 73 74 77 84 87 88 90
|
||||
78 82 85 87 93 96 99 97
|
||||
70 74 75 77 82 82
|
||||
51 55 62 65 67 71
|
||||
29 33 39 42 43 49
|
||||
75 81 84 87 89 91 92 95
|
||||
24 31 34 37 40 42 41
|
||||
72 79 82 84 85 88 89 89
|
||||
71 76 79 80 82 86
|
||||
2 7 9 12 15 21
|
||||
29 35 32 35 37
|
||||
25 31 28 31 32 34 32
|
||||
79 85 88 87 88 91 91
|
||||
23 28 29 31 29 30 34
|
||||
13 18 21 20 22 28
|
||||
14 19 22 23 25 25 26
|
||||
79 84 87 87 90 91 89
|
||||
25 32 32 35 38 38
|
||||
46 52 52 53 57
|
||||
39 45 45 46 47 52
|
||||
33 39 42 46 48 51
|
||||
70 76 77 81 79
|
||||
35 42 46 48 48
|
||||
58 64 67 71 74 78
|
||||
76 82 84 88 89 90 91 97
|
||||
6 11 16 19 21
|
||||
61 66 69 70 75 73
|
||||
55 60 66 68 69 72 73 73
|
||||
3 10 11 18 19 23
|
||||
60 65 67 68 75 81
|
||||
46 44 41 39 38 40
|
||||
40 39 36 35 33 31 28 28
|
||||
97 96 94 92 90 86
|
||||
79 77 76 75 73 70 64
|
||||
88 87 85 86 85 83 81 78
|
||||
81 78 81 80 78 75 78
|
||||
92 91 90 88 86 85 88 88
|
||||
44 43 46 43 42 41 37
|
||||
21 18 15 14 11 13 7
|
||||
97 96 94 92 90 90 88
|
||||
93 92 92 90 92
|
||||
4 3 2 2 2
|
||||
22 20 18 15 12 10 10 6
|
||||
40 38 36 36 34 31 29 23
|
||||
92 89 87 84 83 80 76 74
|
||||
92 91 90 86 84 81 82
|
||||
40 39 35 32 29 27 27
|
||||
85 82 81 79 76 74 70 66
|
||||
73 72 68 65 63 56
|
||||
53 52 51 49 46 41 38
|
||||
83 81 78 76 70 67 69
|
||||
37 34 33 31 29 24 24
|
||||
38 37 31 28 25 21
|
||||
38 37 31 29 22
|
||||
71 74 72 70 68 65 62 60
|
||||
21 24 22 19 20
|
||||
51 54 53 51 49 46 45 45
|
||||
29 31 29 27 26 22
|
||||
35 37 36 33 31 28 26 21
|
||||
48 50 53 50 49 47 44 42
|
||||
30 32 31 28 25 28 25 26
|
||||
69 72 71 73 70 67 66 66
|
||||
54 55 58 57 55 54 51 47
|
||||
60 63 61 63 57
|
||||
15 16 16 13 12 10 8
|
||||
82 83 83 81 83
|
||||
83 85 83 81 81 79 79
|
||||
6 8 7 7 3
|
||||
32 34 34 32 27
|
||||
18 21 18 14 13 10 8 7
|
||||
51 52 48 46 43 41 39 42
|
||||
62 65 63 62 58 58
|
||||
19 20 19 15 14 10
|
||||
66 68 65 61 58 52
|
||||
85 86 85 83 80 78 71 69
|
||||
60 61 60 57 54 48 47 48
|
||||
11 13 11 5 5
|
||||
50 51 48 47 46 41 37
|
||||
49 51 44 43 36
|
||||
88 88 86 85 82 79 77
|
||||
36 36 35 33 35
|
||||
66 66 65 63 62 62
|
||||
26 26 24 22 20 18 14
|
||||
13 13 12 10 9 4
|
||||
79 79 76 73 70 69 70 67
|
||||
41 41 42 40 41
|
||||
5 5 3 6 4 2 1 1
|
||||
8 8 6 9 6 2
|
||||
96 96 93 92 90 92 87
|
||||
33 33 31 30 30 29
|
||||
82 82 80 77 77 76 79
|
||||
19 19 18 18 18
|
||||
64 64 63 62 62 61 60 56
|
||||
54 54 52 49 49 44
|
||||
96 96 93 92 91 90 86 83
|
||||
93 93 90 86 85 82 79 80
|
||||
32 32 28 27 24 24
|
||||
24 24 21 19 17 15 11 7
|
||||
68 68 66 64 63 61 57 52
|
||||
47 47 41 38 37 35 32
|
||||
82 82 81 78 72 70 67 69
|
||||
66 66 64 63 61 60 55 55
|
||||
51 51 50 47 46 41 38 34
|
||||
60 60 57 52 47
|
||||
95 91 90 89 86 85
|
||||
62 58 57 55 52 53
|
||||
27 23 20 18 16 16
|
||||
97 93 90 89 86 83 79
|
||||
61 57 55 52 45
|
||||
60 56 57 55 52 49 46 44
|
||||
58 54 56 55 58
|
||||
87 83 80 78 76 79 76 76
|
||||
33 29 26 23 22 25 21
|
||||
82 78 75 72 71 73 66
|
||||
11 7 6 6 4
|
||||
8 4 3 3 5
|
||||
68 64 64 63 61 59 56 56
|
||||
33 29 26 26 22
|
||||
85 81 78 75 72 72 70 64
|
||||
29 25 23 19 18 15 12 10
|
||||
51 47 45 41 44
|
||||
95 91 87 85 83 80 80
|
||||
31 27 23 22 20 17 13
|
||||
61 57 53 52 51 48 42
|
||||
48 44 42 35 34
|
||||
17 13 6 5 2 4
|
||||
58 54 52 46 43 43
|
||||
89 85 84 82 79 72 69 65
|
||||
83 79 72 70 68 67 61
|
||||
79 74 72 71 68 67 66
|
||||
17 11 10 9 8 7 10
|
||||
83 77 75 73 72 70 70
|
||||
55 48 47 45 42 38
|
||||
64 57 54 53 50 49 47 40
|
||||
65 59 58 56 59 58 56
|
||||
25 20 21 18 19
|
||||
13 8 6 3 6 6
|
||||
75 69 66 64 61 64 62 58
|
||||
45 39 38 37 34 32 34 29
|
||||
26 21 19 19 17
|
||||
23 16 14 12 10 10 11
|
||||
35 28 25 22 20 20 18 18
|
||||
30 25 25 22 18
|
||||
20 14 12 12 10 8 3
|
||||
55 49 48 44 41 40 37
|
||||
24 17 16 12 9 12
|
||||
26 21 18 15 12 11 7 7
|
||||
65 59 57 55 54 50 47 43
|
||||
86 80 79 76 72 69 66 59
|
||||
34 29 27 20 19
|
||||
96 89 88 83 85
|
||||
97 92 89 82 80 80
|
||||
66 59 57 56 53 47 43
|
||||
28 22 17 15 12 5
|
||||
50 50 50 47 46 45 42 44
|
||||
99 95 92 88 85 82 80 80
|
||||
2 3 4 5 7 11
|
||||
81 74 71 73 76
|
||||
42 44 47 49 47 47
|
||||
30 31 30 33 38
|
||||
5 5 8 14 16 18 24
|
||||
97 91 90 87 82
|
||||
27 28 30 32 35 37 37
|
||||
29 25 22 20 21 17
|
||||
38 34 30 29 26 24 20
|
||||
46 39 37 33 33
|
||||
43 39 37 36 33 30 29 25
|
||||
13 17 21 22 27
|
||||
78 71 70 67 65 60 57
|
||||
54 56 54 52 51 49
|
||||
47 53 54 55 56 57 58 65
|
||||
48 48 46 45 44 40 41
|
||||
66 64 61 58 56 54
|
||||
32 33 35 36 38 41 43 46
|
||||
81 84 87 90 92 94 96
|
||||
64 66 67 69 71 72
|
||||
45 46 47 48 50 53 55
|
||||
27 26 23 21 20 17 16 14
|
||||
67 70 73 74 76
|
||||
20 19 17 15 12
|
||||
30 33 35 37 40 42
|
||||
63 62 60 58 57 56
|
||||
7 8 10 12 15
|
||||
52 50 49 47 46 45
|
||||
27 26 24 21 19 16
|
||||
7 8 9 10 11 12 14 17
|
||||
27 26 23 22 21 20 19
|
||||
42 44 47 49 52 53 55 58
|
||||
63 60 59 57 55
|
||||
44 45 48 51 53 54 55 58
|
||||
79 82 85 86 89
|
||||
28 26 25 23 21 18 15 13
|
||||
20 21 22 24 25 26 29
|
||||
54 55 58 60 63 64 66 67
|
||||
25 26 28 31 32 34 37 39
|
||||
40 39 36 33 30 28 26 25
|
||||
41 40 37 34 33 32 30
|
||||
21 24 25 28 29 30 32 35
|
||||
77 76 73 72 71 68
|
||||
67 70 72 74 75 76 77 78
|
||||
68 70 73 76 78 79 82 85
|
||||
53 52 49 48 45 44 43
|
||||
31 33 36 39 41
|
||||
97 94 93 91 89
|
||||
66 69 72 75 78
|
||||
53 56 57 59 60
|
||||
73 74 76 79 81
|
||||
94 91 90 89 87
|
||||
24 26 27 30 32 35
|
||||
40 37 34 31 28 25 23 22
|
||||
36 38 39 40 42
|
||||
87 88 90 93 95
|
||||
71 74 75 76 77 78
|
||||
65 67 70 71 73 74 76
|
||||
42 41 38 36 35 33
|
||||
86 89 90 91 92 93 95 96
|
||||
39 37 36 33 31 29
|
||||
23 22 19 18 15 12 9 6
|
||||
59 58 57 54 52 49
|
||||
71 73 74 77 80 83 85 87
|
||||
10 9 7 6 5 4
|
||||
65 67 68 71 73 76 77
|
||||
18 20 22 25 27 28 29 30
|
||||
83 80 79 78 76
|
||||
24 27 30 33 35
|
||||
18 21 24 27 30 31 34 35
|
||||
84 85 87 89 90 93 94 95
|
||||
66 68 71 73 74 76
|
||||
43 40 38 36 35 32 30 28
|
||||
96 93 90 87 86 84
|
||||
29 30 32 34 36 39 40
|
||||
57 59 60 62 64
|
||||
15 16 17 20 22 25 27
|
||||
37 38 41 44 47
|
||||
62 61 58 56 54 52
|
||||
53 55 57 58 61 63 65
|
||||
11 13 16 17 18
|
||||
63 66 67 68 69
|
||||
6 8 9 10 11
|
||||
35 33 31 29 26 23 20 17
|
||||
35 34 31 28 25 22 20
|
||||
41 43 46 49 51 54 56 58
|
||||
65 68 71 73 76 77 80
|
||||
9 12 15 18 21 24
|
||||
75 74 72 69 67 65 62
|
||||
19 18 16 14 12
|
||||
27 28 31 34 35 37 38
|
||||
37 40 41 44 45
|
||||
38 35 34 31 28 27
|
||||
87 86 84 81 78 75
|
||||
84 83 81 79 76
|
||||
81 79 76 73 72 69
|
||||
34 36 38 41 43 45 46 47
|
||||
73 74 77 80 83 84
|
||||
26 28 29 31 33 35
|
||||
89 90 93 96 99
|
||||
40 43 44 46 48 49
|
||||
15 18 21 24 26 29 30 33
|
||||
89 87 84 82 79 78 76
|
||||
71 74 75 77 78 81 82
|
||||
25 23 21 19 17 14 11 8
|
||||
89 87 85 84 83 80 77
|
||||
60 62 64 66 69 70
|
||||
92 91 88 85 84 82 79
|
||||
77 78 79 81 84 86 88 90
|
||||
34 33 30 28 25 22 21
|
||||
47 48 49 51 52 54
|
||||
41 42 44 46 47
|
||||
69 66 64 63 61 59 58 55
|
||||
55 53 51 48 45
|
||||
57 54 52 51 49 47 46
|
||||
81 79 77 75 72 69 67 64
|
||||
44 46 49 50 52 55 58 60
|
||||
77 74 73 72 69 66
|
||||
74 77 78 80 83 85
|
||||
72 69 67 66 65 63 60
|
||||
63 64 66 69 70 73 74 77
|
||||
34 35 37 40 41 44 45
|
||||
78 77 74 71 70 67 66 65
|
||||
73 71 68 66 63 62 60
|
||||
81 79 78 77 75 73
|
||||
85 82 79 78 77 75
|
||||
94 92 90 89 88
|
||||
35 37 38 41 44 47
|
||||
85 84 82 81 79 78
|
||||
48 49 50 53 54
|
||||
11 12 13 15 17 18 20 22
|
||||
26 24 22 19 16 15 14
|
||||
20 17 16 15 14 11 10 7
|
||||
80 83 84 85 86
|
||||
36 37 38 41 43 44 45 46
|
||||
77 76 75 74 72
|
||||
15 16 17 20 21 24 27 29
|
||||
67 70 71 73 74 77 78
|
||||
89 86 85 83 80 77 74
|
||||
52 50 47 45 44 43
|
||||
30 29 28 27 24 21 19 18
|
||||
89 86 83 81 79
|
||||
81 84 87 89 92
|
||||
23 24 26 29 31 33 35
|
||||
97 95 94 91 90 87
|
||||
75 72 71 69 68 66 63
|
||||
65 67 70 73 76 77 80
|
||||
39 38 35 33 30 28
|
||||
59 62 63 66 68
|
||||
13 16 19 22 25 28 29
|
||||
28 30 32 33 34 36 39
|
||||
63 60 58 55 53 52 49
|
||||
40 42 44 46 47
|
||||
35 34 31 30 27 24
|
||||
70 67 65 64 61 58
|
||||
9 10 13 15 16 18 20 21
|
||||
92 95 96 97 98 99
|
||||
55 54 51 49 47 44 42
|
||||
21 18 16 15 14 13 10 8
|
||||
41 39 38 37 35 33 31
|
||||
20 21 22 23 25 26
|
||||
31 32 35 37 39 40
|
||||
2 4 6 9 11 14 17 20
|
||||
51 54 56 59 62
|
||||
43 40 38 35 34 33
|
||||
87 86 84 82 80 78 77 74
|
||||
43 46 47 50 53 56
|
||||
41 39 36 35 33
|
||||
90 87 86 84 82 79 77
|
||||
64 63 62 61 58
|
||||
60 58 55 54 52
|
||||
37 34 32 29 28 26
|
||||
87 85 83 82 79 77
|
||||
82 83 84 87 90
|
||||
22 21 20 18 16 13
|
||||
20 23 24 26 29 31 32 34
|
||||
45 47 48 49 50 53 55 57
|
||||
82 85 88 90 93 96
|
||||
40 37 35 32 29
|
||||
42 39 38 35 33 30 29 26
|
||||
32 30 27 24 21 18
|
||||
97 94 91 88 85 83
|
||||
52 50 47 44 41 40
|
||||
97 95 92 91 90 88 85
|
||||
61 64 67 70 71 72 73 75
|
||||
63 61 60 58 56 53 51 48
|
||||
57 60 61 64 67 68 71 72
|
||||
17 18 21 22 23 24
|
||||
26 29 30 33 35 37
|
||||
90 88 86 83 82 81 79
|
||||
73 74 75 76 77 78 81
|
||||
46 48 51 54 56 59 60 63
|
||||
88 86 84 81 78 76 73
|
||||
22 25 28 30 33 34 37 38
|
||||
76 77 79 81 84 87 88
|
||||
1 2 3 6 8
|
||||
34 33 32 29 28 27 25 22
|
||||
68 69 70 73 76 79 81
|
||||
46 45 44 42 41
|
||||
78 75 73 72 69
|
||||
83 82 81 80 79 77 76
|
||||
47 50 52 54 56
|
||||
33 36 38 39 42 45 46
|
||||
78 75 72 70 69 66 64 63
|
||||
45 47 48 50 51
|
||||
22 21 18 16 13 11 9 8
|
||||
53 56 57 59 61 62 64
|
||||
35 33 31 28 25 24 23
|
||||
13 12 10 8 6 5 2 1
|
||||
19 16 14 13 10 7 6 4
|
||||
33 36 39 41 42 44
|
||||
57 59 60 63 65 68 69 70
|
||||
41 38 37 35 32
|
||||
85 82 80 77 75
|
||||
51 54 57 59 62 64 65
|
||||
36 38 40 41 43 45 46
|
||||
83 86 87 90 92 93 94 96
|
||||
58 55 54 51 49 47 44
|
||||
61 58 56 53 52 50 49 47
|
||||
19 16 13 12 11 10 9
|
||||
47 46 43 41 38 35
|
||||
71 68 66 63 62
|
||||
81 84 87 90 91 93 96 98
|
||||
6 7 9 11 13 15 18 21
|
||||
78 79 82 84 86 89 91
|
||||
29 31 33 35 36 37 38
|
||||
60 62 64 67 69 70 71 74
|
||||
66 69 71 72 74 75
|
||||
50 53 55 57 58 59
|
||||
51 53 54 57 59
|
||||
12 11 10 9 7 6 5 2
|
||||
41 44 47 48 50 51 52 54
|
||||
55 54 52 51 48 47 44 41
|
||||
46 45 44 41 40 37 35
|
||||
62 61 59 56 53 51 48
|
||||
81 84 85 86 89 90 93 95
|
||||
24 25 28 29 32 35 36 39
|
||||
46 43 41 40 38
|
||||
15 13 10 7 5
|
||||
81 78 76 75 74
|
||||
61 62 65 67 70 73
|
||||
43 40 39 36 33 32 31
|
||||
49 46 44 42 39 37 35
|
||||
27 28 30 31 33
|
||||
52 51 48 47 45 44 42
|
||||
38 35 33 31 28
|
||||
3 6 9 10 13 15
|
||||
36 33 31 28 27 25 22 19
|
||||
18 19 22 23 25 27 30 31
|
||||
28 31 34 36 39 40 42 45
|
||||
96 94 91 90 88 87 84
|
||||
36 37 39 40 43
|
||||
89 87 86 83 80 78 76 75
|
||||
93 92 91 88 86 84 83
|
||||
91 90 88 87 84
|
||||
64 63 61 60 57
|
||||
52 55 57 60 63
|
||||
11 12 15 16 17 20 22 25
|
||||
93 90 87 84 82 80 77 74
|
||||
84 81 80 78 77 75 72
|
||||
34 35 36 38 39 40
|
||||
65 67 68 69 70 73
|
||||
81 79 78 76 75 72 69 66
|
||||
88 87 86 85 82
|
||||
44 43 41 40 39 38 37 34
|
||||
76 79 80 83 86 87 89 92
|
||||
22 21 19 18 16 15 13 11
|
||||
60 61 64 67 69 70 71 72
|
||||
75 76 77 80 81 82 83 84
|
||||
66 63 61 59 57 54 52
|
||||
72 71 68 67 64 61
|
||||
78 77 74 71 70
|
||||
67 64 62 61 58 57 55
|
||||
27 29 32 33 36 37
|
||||
14 13 11 8 7 5
|
||||
51 54 55 56 58 61
|
||||
36 37 38 40 41
|
||||
19 21 22 24 27 30 33
|
||||
61 58 57 55 54 52 51 49
|
||||
80 82 84 87 89 91 93
|
||||
93 92 89 88 86 83 82
|
||||
79 76 73 70 68 66
|
||||
24 22 21 20 17 14
|
||||
17 14 11 8 7
|
||||
87 86 85 82 80 77 76 75
|
||||
14 13 11 10 9 7 4 1
|
||||
82 85 87 90 93 95
|
||||
58 55 54 52 51 50 49
|
||||
60 59 57 54 53 52
|
||||
80 77 75 72 69 67 64
|
||||
45 46 47 49 50 53
|
||||
91 90 87 86 84 82 81
|
||||
69 70 71 72 73 76
|
||||
85 84 81 79 77
|
||||
21 20 17 14 11 10 7
|
||||
68 67 65 63 62 60 58
|
||||
34 35 37 38 41 42 44
|
||||
12 13 15 17 20 22 25 27
|
||||
18 16 15 12 10 9
|
||||
20 17 14 13 11 9 8
|
||||
67 65 63 62 59 57 55
|
||||
88 91 92 93 94
|
||||
91 90 88 86 84 82
|
||||
66 64 62 59 56 54
|
||||
78 76 75 73 71
|
||||
71 68 65 62 61 60 57
|
||||
56 57 59 62 63 65
|
||||
30 28 26 25 22
|
||||
82 81 78 77 76 74 73
|
||||
54 52 49 48 46 43 40
|
||||
59 58 57 54 51 49
|
||||
80 81 82 83 86 88 90 91
|
||||
85 83 80 79 77 75 72 71
|
||||
87 89 90 91 92 94
|
||||
13 14 16 19 22
|
||||
29 28 25 23 22 20 19
|
||||
21 22 24 27 29 32 34
|
||||
11 8 6 5 3
|
||||
65 63 62 60 58
|
||||
32 35 36 38 39 40
|
||||
38 39 40 43 44 45
|
||||
43 40 37 35 33 30 27
|
||||
10 7 6 5 4 3
|
||||
4 5 8 9 11 13
|
||||
87 90 93 95 97 98
|
||||
68 69 70 73 74
|
||||
65 62 61 60 58 56 53
|
||||
53 54 57 60 62 64 65
|
||||
57 58 59 62 64 66 68
|
||||
56 54 52 51 48 47 45
|
||||
87 90 91 94 95 96
|
||||
93 92 90 89 87 85 83 82
|
||||
3 6 9 11 12
|
||||
35 32 31 29 28
|
||||
82 81 78 77 74
|
||||
10 12 14 15 18 20 23 24
|
||||
60 59 58 57 54 53 51
|
||||
37 34 33 30 28 26 24
|
||||
22 20 18 16 14
|
||||
15 18 21 23 25
|
||||
19 17 14 13 12
|
||||
20 18 16 14 11 10 8
|
||||
84 83 82 80 78 76 73
|
||||
11 12 13 16 19
|
||||
59 56 55 53 51 50 48
|
||||
81 79 78 76 75
|
||||
4 7 9 10 12 13 16 17
|
||||
1 3 5 6 9 11 14 15
|
||||
24 27 30 32 35 37 38 39
|
||||
50 48 46 45 43 42 39 37
|
||||
53 51 49 48 45
|
||||
82 81 80 77 74
|
||||
38 37 34 31 29 27 24
|
||||
77 78 79 82 85 88
|
||||
66 63 62 61 58
|
||||
40 39 36 35 32 29
|
||||
16 13 10 7 6 5
|
||||
39 36 33 32 30
|
||||
90 88 86 84 81 80
|
||||
91 88 86 83 81 79
|
||||
87 86 83 81 79 77 75 72
|
||||
10 11 12 14 16
|
||||
20 23 25 27 28
|
||||
64 66 69 70 72 73 76 77
|
||||
89 88 85 82 80
|
||||
24 23 20 19 18 16
|
||||
59 56 55 53 51 49
|
||||
99 97 94 91 88 86 83
|
||||
27 24 22 20 17 16 15 12
|
||||
84 87 90 93 94 96 98 99
|
||||
37 38 41 44 46
|
||||
21 22 25 27 29 30 32 33
|
||||
18 19 21 23 25 27
|
||||
30 29 27 26 25 22 20
|
||||
82 80 78 76 74
|
||||
23 25 28 30 31 32 35 38
|
||||
19 16 15 13 10 7
|
||||
84 85 86 87 88 89
|
||||
86 84 83 80 78 76 75 73
|
||||
9 10 12 14 15 18
|
||||
18 21 23 24 25 28 29
|
||||
52 51 49 46 45 44
|
||||
11 14 16 17 20
|
||||
39 38 37 35 34 32 29 26
|
||||
66 63 61 58 55 52
|
||||
99 96 94 93 90 88 85 82
|
||||
51 50 47 46 43 41 38
|
||||
70 68 67 65 62 61 60
|
||||
86 83 81 78 75 74 73 71
|
||||
33 31 28 26 24 21 19 17
|
||||
53 50 48 46 45 43
|
||||
15 14 13 10 7
|
||||
49 46 43 40 37
|
||||
79 80 81 84 85
|
||||
1 4 5 8 10
|
||||
34 33 30 29 27 25
|
||||
11 9 7 4 2
|
||||
77 74 73 70 68 65 62 61
|
||||
88 87 84 82 79 77 74
|
||||
46 45 43 40 37 36 34
|
||||
47 49 52 54 57
|
||||
16 17 20 21 22 25
|
||||
27 25 23 22 19 16
|
||||
76 73 71 69 66 63 60
|
||||
57 58 59 62 65 68
|
||||
52 50 47 44 43 40
|
||||
69 66 63 60 59 57 56
|
||||
30 32 35 36 38 39 40
|
||||
12 15 16 17 19 20 22 23
|
||||
68 67 64 61 58 55 52
|
||||
67 66 64 62 60 58 55
|
||||
71 69 66 65 64
|
||||
85 84 82 80 79 78 77
|
||||
10 13 16 18 19 20
|
||||
49 52 53 56 57
|
||||
24 21 18 16 13 11
|
||||
95 92 91 88 87 84
|
||||
80 82 84 85 88 89
|
||||
46 47 49 51 52 53 54
|
||||
17 14 13 12 10
|
||||
66 67 69 71 73 76 79 82
|
||||
52 49 48 45 42 39 38 36
|
||||
79 82 85 88 90
|
||||
84 86 89 90 92 95
|
||||
69 71 73 75 78 80 81
|
||||
28 30 33 36 38 40
|
||||
31 33 35 36 39 40 42 44
|
||||
58 59 62 63 64 67 70 71
|
||||
63 66 67 68 71 72
|
||||
72 73 75 78 80 83 84
|
||||
66 64 62 61 60 58 57 56
|
||||
55 57 58 59 60 62
|
||||
75 76 78 79 81 84 85 88
|
||||
75 74 73 71 69
|
||||
91 88 87 84 83 81
|
||||
22 21 18 17 15 14
|
||||
81 83 84 85 87 90
|
||||
18 16 13 12 11 9 6
|
||||
55 54 51 50 47
|
||||
11 14 15 16 17
|
||||
80 77 74 71 69 67 64 63
|
||||
94 92 91 89 88 85 84 82
|
||||
61 58 57 56 54
|
||||
76 77 80 82 85 87
|
||||
67 65 63 62 61
|
||||
27 25 24 23 21 18 15 12
|
||||
43 40 39 37 36
|
||||
89 87 84 81 79 77
|
||||
57 59 60 63 65 68 71 73
|
||||
96 93 91 88 86 84 83
|
||||
62 59 58 56 54 52 51
|
||||
30 32 35 38 41 42 44
|
||||
24 22 19 17 15 12 11
|
||||
34 33 31 28 26 25
|
||||
5 7 8 11 13
|
||||
48 46 43 40 37 36
|
||||
39 36 33 30 27 26 25
|
||||
51 48 46 43 41 38
|
||||
52 51 50 47 46 45
|
||||
57 55 54 51 50
|
||||
61 59 58 55 52
|
||||
38 36 35 33 30 27 24 23
|
||||
73 72 70 67 66 63 61
|
||||
33 30 29 27 24
|
||||
97 95 94 91 90 88 86 83
|
||||
81 79 76 75 73 72
|
||||
8 9 12 15 17 19 21
|
||||
26 29 31 32 34
|
||||
88 86 85 83 80 78
|
||||
76 78 80 81 82 83 85 86
|
||||
15 12 10 7 6 3 2
|
||||
33 32 29 26 24
|
||||
32 31 29 28 26 23 21 18
|
||||
88 87 84 83 81 80 79 78
|
||||
33 30 28 27 25 22 21 18
|
||||
58 61 64 67 69 72 75
|
||||
45 44 42 39 37 35
|
||||
85 84 81 80 79 77 76 74
|
||||
58 57 55 52 51 50 47
|
||||
58 57 54 53 52 50
|
||||
75 73 72 70 67
|
||||
27 26 24 22 21
|
||||
24 23 20 17 15 14 12
|
||||
30 29 27 25 24
|
||||
81 80 78 77 74 73 71 70
|
||||
58 57 56 53 50 47 46 43
|
||||
85 88 90 93 94
|
||||
91 89 88 85 84 82 80 77
|
||||
16 19 22 24 25 27 28
|
||||
23 26 29 31 33 34
|
||||
87 88 90 92 93
|
||||
55 57 58 59 62 63 66
|
||||
25 26 27 30 31 32
|
||||
90 92 95 97 99
|
||||
48 49 51 53 56 58 60 61
|
||||
31 33 35 36 38 41
|
||||
53 54 56 57 59 62 63
|
||||
56 59 61 64 65
|
||||
49 48 45 44 42 40 38
|
||||
66 65 63 60 58 56
|
||||
38 41 43 44 47 50 53
|
||||
2 3 4 6 9
|
||||
@@ -0,0 +1,88 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
aoc "go.sour.is/advent-of-code"
|
||||
)
|
||||
|
||||
// var log = aoc.Log
|
||||
|
||||
func main() { aoc.MustResult(aoc.Runner(run)) }
|
||||
|
||||
type result struct {
|
||||
valuePT1 int
|
||||
valuePT2 int
|
||||
}
|
||||
|
||||
func (r result) String() string { return fmt.Sprintf("%#v", r) }
|
||||
|
||||
func run(scan *bufio.Scanner) (*result, error) {
|
||||
|
||||
sum := 0
|
||||
sum2 := 0
|
||||
|
||||
for scan.Scan() {
|
||||
txt := scan.Text()
|
||||
row := aoc.ReadStringToInts(strings.Fields(txt))
|
||||
|
||||
good, bad := testSafety(row)
|
||||
if good {
|
||||
sum++
|
||||
sum2++
|
||||
continue
|
||||
}
|
||||
|
||||
for i := max(0, bad-1); i < min(bad+2, len(row)); i++ {
|
||||
arr := cut(i, row)
|
||||
|
||||
good, _ := testSafety(arr)
|
||||
if good {
|
||||
sum2++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &result{valuePT1: sum, valuePT2: sum2}, nil
|
||||
}
|
||||
|
||||
func testSafety(row []int) (bool, int) {
|
||||
good := true
|
||||
bad := -1
|
||||
increasing := false
|
||||
decreasing := false
|
||||
|
||||
for i, v := range row[1:] {
|
||||
if v > row[i] {
|
||||
increasing = true
|
||||
}
|
||||
if v < row[i] {
|
||||
decreasing = true
|
||||
}
|
||||
|
||||
if difference := aoc.ABS(v - row[i]); difference < 1 || difference > 3 {
|
||||
good = false
|
||||
bad = i
|
||||
break
|
||||
}
|
||||
|
||||
if increasing && decreasing {
|
||||
good = false
|
||||
bad = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return good, bad
|
||||
}
|
||||
|
||||
func cut(i int, values []int) []int {
|
||||
arr := make([]int, 0, len(values))
|
||||
arr = append(arr, values[:i]...)
|
||||
arr = append(arr, values[i+1:]...)
|
||||
return arr
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/matryer/is"
|
||||
)
|
||||
|
||||
//go:embed example.txt
|
||||
var example []byte
|
||||
|
||||
//go:embed input.txt
|
||||
var input []byte
|
||||
|
||||
func TestExample(t *testing.T) {
|
||||
is := is.New(t)
|
||||
scan := bufio.NewScanner(bytes.NewReader(example))
|
||||
|
||||
result, err := run(scan)
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.Equal(result.valuePT1, 2)
|
||||
is.Equal(result.valuePT2, 4)
|
||||
}
|
||||
|
||||
func TestSolution(t *testing.T) {
|
||||
is := is.New(t)
|
||||
scan := bufio.NewScanner(bytes.NewReader(input))
|
||||
|
||||
result, err := run(scan)
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.Equal(result.valuePT1, 486)
|
||||
is.True(result.valuePT2 > 517)
|
||||
is.True(result.valuePT2 > 523)
|
||||
is.Equal(result.valuePT2, 540)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
|
||||
@@ -0,0 +1 @@
|
||||
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))
|
||||
@@ -0,0 +1,6 @@
|
||||
)+when())~why(),),mul(712,171)@}-?}mul(506,85)who()%mul(613,601)/;#from()#mul(977,581)~what()?/$^-+(*mul(142,89)[who();*):*mul(64,644)}when()select()mul(652,872)mul(594,202)?%$when(196,699)mul(311,646)<>/how()where()(+:mul(867,971)}&where()'/&[&$mul(192,659)select();<#}mul(367,411)mul(841,862)when()(%!mul(922,272)^;}mul(593,223)mul(918,232)mul(760,145)]^?why()>mul(558,476)where()who()&do()^]($,~&-{where()mul(855,134),(--{mul(691,389)+mul(352,712)why()<(]'/}-mul(138,405)$where()mul(176,679) from()'!why(){:mul(516,55)%*>mul(97,636)mul(30,945)**~what()$,mul(486,399)# ,~~!]mul(277,667);~$[from()how()&mul(412,36)([@@,what()% mul(478,68)&mul(293,979)mul(218,379)~)'?-&from()@mul(887,161)(mul(156,481)who();&[:mul(308,96)mul(718,985),] when())/~>^$mul(84,469)*<where()how()[mul(257,600)<~mul(660,909)select()mul(510,180)what()mul(619,634)#mul(721,403)why()@!,~:>where()mul(500,291)who()])]*don't()who()select()^;,@mul(837,399)$(,(-who()}'mul(835,602)~:]mul(99,872)how()what()<select()how()(don't()[[@, ,mul(962,879)who()])mul(828,134)$where()when())>%{who(794,618)>mul(227,398)why()where()-why()what()^/:; mul(753,183)[{ ]#^#%%~mul(196,63)}%don't()who()$ :how(),select()~@mul(214,483),:select()%)}who()mul(198,36)*do()what()mul(330,804)what():+>mul(10,447)*/!mul(580,733):&where()'mul(247,9)$)[:#-select()?do()mul(157,768)why()/ who()$from()where()don't()mul(527,694){how(206,792)mul(314,331)/from()/what()#mul(49,792)',-(why()#/]mul(645,190)from()$?mul(775,2)!+select()+^]from(104,329)!mul(287,711)}select():){mul(770,682)!don't()! *^+ when()]%-mul(291,143)mul(956,213)[[>{%'#*{~mul(569,514)[}how()@;mul(291,643)what()%&-where()#@<mul(729,139){^mul(501,801)]mul(261,648)}+~>when()mul(678,494)>%mul(303?<%where()what()mul(601,775)mul(91,748)&why()mul(648,173)~*mul(101,949)*:}>'from()-what()^}mul(890,865)what()mul(398,428),select(261,665)where()when()+mul(315,619what()mul(301,311)^~ where(297,851)#{!+&:mul(548,329)mul(239,714)who()@why()(#+!select()why()do()when()mul(249,859)}<select()&mul(239,140{from(149,864)]#]*~ mul(382,788)select(519,600)select(),from()(mul(350,980)@([-,~~%select()mul(710,125)what()how()]-/where()from()%mul(621,643)+what()~!how()what(814,400)<>>@mul(174,437)how(131,486)mul(294,93)mul(605,381)@#}what():~mul(873,431)#)who()^<why()mul(463,819);mul(961,13)what()why(474,300)@}&!]mul(507,494)/@}mul(636,958)^ ~from();!where()how()mul(801,95#; ;<when()who()*(mul(539,800))don't()mul(361,163)>how()select()from()#mul(411,803)-(>why(){{mul(400,846)mul(705(~+%mul(235,314)how(),where()++<{mul(795,270)how()#? $'*select()mul(301,531)mul(109,954)/mul(451,416)%%!select()mul(834,747)%select()[ mul(457,765)do()when()@<!how()mul(520,202):where(41,552)!'&@-,$mul(493,844)-?'*what()when()<^mul(937,957)who()where()who()mul(301,646)/^select()#;how()}select()mul(954,724)mul(695,132))*%mul(976,455)when()**from()]what()@how()')mul(492,975);what();^''#/?~mul(258,829)#*how()#>mul(779,58)('who()mul(275,708)
|
||||
])$&mul(546,476)&]mul<}~mul(490,931) why()>~)from()@mul(302,82)mul(625,374)-;>%where()mul(864,633):!-,how()when()mul(748,5)what()!how(447,20)]what()/where()<'}don't()from()}why()mul(837,78)what()&:%where()?mul(402,690)mul(689,472)(:{+&}*+mul(915,883)}?)#from(62,762)-mul(512,958)+who()$#^{*mul(798,476{:@who()#mul(89,309),how()!what()what()where()mul(613,761)^[~~:&do()>mul(375,874))?{why()'@mul(75,714)!<%why():!don't()select()?when()@:?<[~mul(43,740)mul(389,134{'(~- >who()mul(755,490)when() what()mul(391,722);what()mul(107,927)~mul(901,762)+;when()+$^select()mul(609,510)#how():select()@)mul(937,386)) +&){mul(757,236)?how()/[who()'*how(937,357)&when()mul(521,787)where(954,730)#what()^mul(158,498)+mul']do() select()}$mul(60,389):~/;;#where()^mul(958,451)*!{{ %/#:mul(855,921)]mul(558,622))-mul(269,240)+how(626,93)+,$(!mul(735,376)%%[where()mul(868,976)~& @;]mul(597,168)from()what()select()@what()mul(40,231):who()({&who()~don't()+~who()-mul(693,922)/why()mul(597,656)mul(826,321)when()mul(793,429)select()~:~}how()how()@mul(837,77)when()mul(389,114)@mul(362,967)+mul(342,929)#where()~mul(218,879)--+[%]who(933,163)mul(314,457)'&/&,)(mul(362,966)<?]^~mul(179,657) do()!from(898,248)?:where()<when() ~when()mul(512,132)(@$?when()$how()@how(50,144)mul(570,592)from(847,182)]what();mul(530,540)}'mul(20,999)why()::mul(801,920)/)where()how()mul(984,512)}who()<]where()mul(698,898);when()-from(552,362)>- ^how()>mul(890,685)[;$;#where()how()+mul(239,920):(@;%when()+mul(88,839)&^)@why()what()how()where()[mul(572,398)what()$mul(752,549)what()when()'>[<when()<?mul(10,251),^~from(),where())#mul(569,478)where()~select()'mul(411,622)^-'+{mul(784,824)mul(641,531)mul(315,701)[mul-^(%when()mul(824,525)#$@*:+:}>mul(732,854)(+@ {(who(621,788) mul(86,481)how()@*'mul(954,533):how()'from()}-when()mul(826$]}how()mul(482,558){%what()^/&)}^[mul(45,414)}how(){;&how()~#mul(300,115)*)?select()<]%mul(374,474){#select()#mul(215,47)who(){^++?%{&mul(332,567)$mul(357,321)/from()#( why(496,793)mul(501where()@}who()select()}mul(62,985),!select()}#+{{]mul(211,725)?]< :how()select()mul(958,722)#'where()!what()@$mul(157,358)mul(998,511)mul(97,681)*;mul(206,463))*mul(790,146select()when(199,114)&[%!';select(){who()do()mul(960,474^}+why(960,681),~>[why(701,791)mul(865,506)?-;select()/~@do()+{'what()~select()%+mul(638,544)) >$^*<where()select()(mul(501,647)@#~when(136,478)()*;^mul(48,956)how(),what();^^when()from()^mul(501,473)what()!what()mul(820,536)}mul(772,914)+-$from());+?-#mul(76,607)//mul(705,35)who()*what()!{how()mul(733,730)from()*where()+<mul(821,893)mul(947,531)select()^who(),{how()where(610,667)where()mul(889,663)where()where()#/^mul(493,430)^mul%why()-?what()mul(139,704)@select()mul(923,691)>mul(583,859){[mulhow()>who()/?^~%mul(19,182)~select()select()select()**+mul(77,374)&@??when()>[mul(630,751)mul(740,291)){@*{what()what()@&who()mul(760,727)where()<^ >][mul(996,13)}{%*when()+*mul(865,56)*]mul(995,58)how()}what()@!!)';(mul(323,37)~mul(348,89);{when()~)'mul)'>what()<$%who()%don't()from(533,539)?'~-'where()-+?mul(917,600);from(672,658)mul(966,120)/'@/'^mul(895,427)mul(842,971)',@mul>who(){mul(670,166)where();)^don't()~$+#:when()?!mul(871,536)who(67,974)do()##select()>+(#mul(502,269)!$[^where()where():where()mul(652,742)
|
||||
from()#%;why()(why()?mul(43,859){(who()]-:{mul(162,15):>how()@%$:mul(322,158)what()$&*{how()mul(949,468)where()?what()+mul(890,635)@;mul(937,114&+:where()#mul(516,431)who()mul(516,755),}who()'!mul(484,114)*}who()who()]mul(623,440)!%{{why()how()}mul(774,302)&)[{select(873,278)-@mul(91,958)<}?-,>+/from()}mul(910,920)']:~how(996,958))why()@mul(134,589)<''when()mul(853,477*$!mul(204,437) where()#how()>~who()*mul(697,199)[-~}select()mul(928,999)!what()when()!>mul(721,616) }why()%)mul(166,276),^$$[when())-why()mul(921,345)&when()'how()-mul(858,22):when()mul(812,54)how()%@%^&mul(11,654)where()^!)%mul(398,677)what()what()[/$:who(279,228)#mul(649,529)mul(78,877):mul(265'&}!why()how()mul(826,788){*:{?,who():mul(463,163)select()mul(342,950)mul(339,663)from()where(){,who()<:?why()when()mul(568,433)$,select()?mul(182,776)^/*,<%*select()%mul(705,962)what();}mul(717,100)from()mul(664,69 % *mul(423,876);from() who(),mul(630,98)[:?how()from(718,704)mul(356,570)#why()select()')from()@:mul(193,467)when() !!)select(625,819)/(!when()mul(171,718)do()<:,what();select(){$}?mul)+mul(20,284)$/,~from()],^mul(984,419);; mul(503,701)+[(;select()?/mul(634-how()mul(424,769))~ -where()* }who(484,481)how()mul(707,101)*do()where())select()(from()]#who(335,623)when()who()mul(911,436)what()<mul(194,212),why()/>}mul(777,219)what()['}when():select()mul(948,616)<from()$,#mul(553,209;;)-;what()*mul(728,277)?-{select()[when()^@'@mul(587,483);^%mul(399,787)&{who()$,mul(915+what()!why()}!who(610,136)+what()mul(226,744)*@from()@):]mul(384,508)when()-how()mul(71,783)#mul(358,304)/select(114,878) [}where()why()%)?mul(45#]when()'*+when()who()mul(914,176)when()@(who()&select()&mul(326,407)mul(506,431)what()})^$}~&*{mul(906,775)from()where()(]~mul(969,415)mul(710,613)+*select()mul(312,425)():}^!{*)mul(766,549)from()<:[/%'mul(782,679)'!select()~#>%/mul(476+&!&who()'<how()who()(mul(876,214)select();&from()'mul(120,331) !~',/mul(276,127)]%]who()([-what()mul(36,647)how(144,302)&^from()%mul(166,678)who()mul(577,776))+&>>@]'mul(540,542)select()%when() mul(21,652)^#why():?,![<mul(696,919)!why()when()>where(),+#{+mul(957,516)select()@who()!mul(949,720)$ >from()[>when()@mul(302,42)*when()};mul(62,497>~~)@<mul(730,949)how()from()>how()why()*(mul(664,358),mul(739,738)?/)from()//mul(377,419)}{-what()~why()^[]mul(40,477]#+?]don't() when()]mul(870,3)why();%?-how(721,560)$);[mul(568,692)+~how()mul(638,590)~% ?]mul(901,665)+:;?mul(518{&(+~/#when(87,181)@what())mul(675,719)}why() do() ;^mul(596,35) )mul(427,664){<mul(197,195)@/~#when()do()>when()what(){select()+%}mul(737,893) mul(709,889)!-@,when();where()mul(129,840)when()mul(920,817)#]?^?why())@@mul(269,369) mul(828,795)@*;where()mul(682,546)from(){/mul(243,207)mul(503,124)[from()where()&what()&}(mul(750,321)how()>'&)mul(970,615)why()~mul(876,7)&:%select(836,319)$who()&mulwhere())/]{mul(312,66) ~'%why()from()mul?{select()] ;?*?select()mul(453,529)why(117,235)^do()@'-+from(370,703)mul(644,160)<[,mul(227,457)~}%%select()^>select(360,884)]mul(925,534)-select()'mul(739,218) &/&how()~^mul(332,459) (&{!select(856,366)-don't()()when()-from(487,696)%?what(768,731)mul(745,482)[,select()mul(880,43)^why()mul*@[[+where()what()how()mul(546,582)from()[/&why()mul(308,97)mul(343,420)}when()~mul(824,505)why()?!who(),mul(261,37)what(580,629)^-mul(554,10)$} %)?^*+mul(519,543)!{&#*mul(71#+select()&'why()*mul(67,843)~>where()]mulwhat()where()/[what() who()(/@/#!/usr/bin/perl&>mul(708,675)
|
||||
@from()[$from()why(548,875)mul(121,80)}:$-mul(4,306)mul(763,819)how()~)}'<who()why()when()mul(496,223)select()]don't() (mul(667,275)*who()?&+[do()+)&,what()#/mul(345select() what()mul(173,615)$/;select()select()~mul(942,267)[/^<!',<why()how()mul(32,848[<select()&~+mul(428,140)mul(601,739)who()how()select()}@how()@>what()do()mul(185,413)*don't()how())>:-]mul(988,832)from()#? what():how()~what()?mul(186,334)select()mul(302,939)*&{#+:)+do()[~+'mul(981,447)do())(how()where()&what()?][&mul(31,754)$?*^+-%(>)mul(851,878))>what()^#$do()]?,)mul(470,861)/!what()mul(861,914)@}when()when(535,739)/where()mul(404,36)why()where()do():}mul(192,10){,from()]!'!when();mul(439,983)when()?*where()who()mul(264,570)/where())mul(118,609>~])&<;+what()}mul(740,187)-!why(),{- <&mul(515,176)why()(#&?$who())^mul(861,78)mul(425,831)^*}don't()&);how()]mul(983,533)/mul(871,157)why() why()mul(822,445)*?>/{}what())mul(466,451)what():+?mul(362,799)select()@{~^^mul(808,226),mul(847,636)how()'select()+?mul(965,149)##?~mul(898,404)$select()! mul(704,590)~mul(453,171)!:why()#^< mul(667,115)>select()from()who()how()?/<how()mul(130,444),[how()(%+,from();mul(886,298),]-~when() >mul(689,875)why()what()})&!&mul(51,975)^]what();:when()don't()[;$ where()why()mul(71,129)who()%mul(841<@<mul(464,159)>mul(61,222)$;[#~~mul(433,310)>from()how(932,844){?-%mul(172,290)select()''how()*-where()%when()mul(868,592),(select():*:/mul(313,54)}from()how()^*]-where()+do()(--select()what(),/ mul(867,197)mul(203,803)+when()%;-where()%<-don't()]]@where()why()!#why()!mul(949,149)]?mul(960,580)how()mul(12,600));mul(210,348)*mul(565,871)'%where()mul(577,267)!#)mul(474,282)<<from(){where()&<)when(){mul(534,990)how())mul(348,523)how()+[*'select(){{mul(610,625){-mul(125,779select()!from(){)*what()mul(237,916)mul@]how(),;{@select()~do()) @;?who()~<#mul(641,477)%select()/*mul(66@/# ]#when()/,-@mul(398,141))where()*mul(17,892)mul(447,218*from()}~~%%::,<mul(581,913)what()who()/@+*who(507,341)mul(485,202)mul(637,719)@~!]]%[}mul(152,221)who()where()select()^why()<@(mul(336,492)who()>#>%when(255,810)(mul'why()+*when()how()~->]mul(76,674)what()}}%where()where(552,574)mul(172,533)why()mul(166,405)(from()#/how()how() ^^(mul(580@( ^how()from()mul(168,469)}]@how()~mul(319,476)^]from()(what()'>/,^mul(953,57)# how()select()mul(534,477):select(791,428)~$,when()mul(504,444'mul(534,163)where()# %why()!mul;,why()from()}'mul(819,924):mul(914,787) #?select():!+%];mul(743,314)[?#{mul(127,154)how()+[@!]mul(402,199)!)why(774,912)?~,( where()&mul(747,407)don't()>what()where()'why()why()why(844,133)mul(649,89)mul*when()mul(878,257)!>%#>;select()mul(371,837)-;from()where()~-mul(314,883){}mul(952,191)(-#-mul(400,750)what())what()mul(83,753) +who()!<select()[~<+do()why()?who(){;++mul(315,12)from()%where()(why()%mul(244,473);%-/}*$@do()select()['+*why()from()mul(503,91)why()&(mul(718,938)]!}when(217,970)do()]mul(695,933)^/mul(643,847)!-~%mul(599,777,*{'from()when()}from()?*do()/who()]how()) ]%{mul(128,209)/?mul(145,427):mul(838,702)who()~&^:mul(750,117),why()$when()-;%mul(105,945)!when()%how()$<%;mul(445,716)/,/+'mul(848,545) :;:(from()don't()-/)&{$mul(645,418)select()&'[+%/&mul(805,629)$mul(409,212)when()?where()(%who()why(),mul(341,178){![from()^select();from()when()mul(53,969)<;select()mul(351,259)~]%&/-why()mul(22,26)&]>select()$}mul(79,756)where()^?',-mul(273,582) why()do()&~) what()what()mul(92,844)where()!what()/>> {%mul(678,890)mul(784,836)mul(184,623)
|
||||
who()mul(590,239)%%mul(67,657)when()({]mul(556,689)when()/+: :<mul(570,791)when(500,731),}<--'mul(315,20#mul(353,577)]<mul(147,848)mul(974,10)^from()how()what(){( ?mul(500,481);from()*]'{@mul(145,394)why()where()?]?what()mul(97,499)mul(784,687)^[]:how(823,116)mul(290,184)who(27,581)+[~}}@*(;mul(553,555) when()/mul(317,461)mul(789,586)what(787,924)>(who()$,~])mul(810,145)$from()^/)?(/>mul(468,772)(~(who()mul(663,347)where() #how(572,145)!<&;mul(704,336)%$++!mul(170,815)from();why()mul(944,939)]select()<mul(280,533)why()mul@[who()~:[?)from()/how(159,441)mul(738,82)~ from(858,110))%~~*~mul*mul(488,256)/>!mul(584,361)what()~why()[why()>,~<mul(896,700) ')}who() !>mul(794,457)from()~,how(898,290)don't()mul(889,959)where(594,614):who()*/-mul(786,550)!how()mul(481,863)*!select()who():@mul(980,469)when()-&*#~[*~mul(972,650);&from()$!/:$mul(140,685)]</*%:mul(884,90)select()&}why()!from()&?how()^mulwho()'?select(213,664)why()&why())@^mul(90,714)where()!why()mul(874,305);:$who()+:[mul(5,462)why()mul(102,265)>/~[{where(409,316)mul(232,721)>why()who(902,515)who()$!where()/>mul(247,605)'what()select()mul(936,163)mul(591,955)how()mul(931,542)how();what()'*;where()<mul(224,284)~/@mul(878,735)}>&<(,mul(55,798) ,[+what(){^mul(441,281)?mul(570,318)mul(973,304)}what()]mul(45,721)#?@?where()(<!#mul(38,985)mul(615,729)!^)from() ,}!don't()^,~>>!#mul(701,624)select()[-mul*{mul(67,259)(({%+ -+mul(986,986)&from()who()-'mul(726,819):mul(490,252) what()+how()select()-why(423,93)mul(694,82)-how(328,923)>'how()&(%what()*mul(372,723)'?!!}mul(231,968)-!%mul(415,363){mul(723,230why(141,301)^when()mul(123,44)how()#-who(){&!{mul(513,206)mul(651,372)/#'who()%when()when()^how()mul(894,333)*>mul(789,454)mul(527,63)]}!][#-:mul(696,451)-mul(725,992)/({mul(951,218)/*,who()(];}$mul(999!how()+why()~what()$#)(what()mul(866,336)&when()@!]mul(277#+why()when()where()]mul(625,228)don't()how()*from() mul(728,218)[<&mul(685,966)when()]([':>mul(88,454):,mul(980,618)[:mul(983,851)from() (where()mul(136,951)mul(923,850)select()^what()when()where();{-mul(574,853)'!%select()[how()~)!~don't()>+*mul(999,45)%how()$*^mul(663,51)what() mul(72,914)when()where()^*>';from()mul(717,449)from(116,874)!#}^~$()why()mul(253,711)!-?[where()where()$<mul(413,791)why(),&where()mul(881{:why(457,236)^$mul(579,940)^!+-#[mul(365,458)*what(826,843)mul(905,802)',from()&?*,/who()#mul(706,256):#mul(397,960,/}mul(886,736)@)??mul(483,8):when())where(835,379)'where()who(206,272)mul(41,664)~-^(when()(!:how()mul(65,540)select()where()%from()'{mul(422,122) ~mul(31,555)~select()mul(368,343)<$$~>-@do()%#+&&why()&?who()mul(575,697)*{mul(124,326) )};}why()/')mul(524,584)from())who()?~mul(245,768)!how()@)mul(704,867)^from()]%$(?when()mul(90,724)-;]why()?mul(434,982)%[$from()/-mul(947,645)%what()from()~*;why();-mul(637,644)mul(728,998how(363,38)]#[mul(968,268)mul(118!}how()who()&+$mul(512,161)/~+mul-who()mul(627,181);when()&do()}#;select(139,567)what()*from()-why()mul(914,709)mul(372,426)select()/select()(:mul(573,160]select():mul(439,918)mul(8,169)&why()^'mul(417,187))([who()/when()who()>mul(715,150)-how(609,180),mul(208,512)'why()':&mul(998,345)
|
||||
[:~from(109,28)mul(762,958)-mul(962,739)%mul(808,716)'{(]},<;mul(937,746)where()select(731,533)select()[,how()}select()who()mul(191,854)where()mul(479,494>*why()mul(453,745)/%/mul(857,414):>who() ?mul(724,307))(<&select()mul(514,942)why()<,where(857,995)why()who()(mul(499,812)how()why()select()@,{@,^$mul(870,75){where()%when()}mul(715,952)mul(679,508)]-*#~mul(976,825)@what(311,818);}>+don't()from()!(mul(831,784)select(401,869)>##what()}$}mul(485,631)%when()don't(){%[<mul(650,982)how()'from()%[/how()/mul(435,53)?&!{how()[::mul(131,389)^,what()/>%where()mul<mul(169,929)*mul(299,197)'(?/mul(615,378)select()>^!'@select()$when(194,342)mul(955,305)when(714,487)!~[mul(132,571)&<<[?}select(424,232)what()mul(728,300)select()where()@>{*mul(695,119)mul(350,526)~/what()when(),?'mul(166,855)%!,who()}why()from()}what()#mul(197,953)from()}from()?mul(608,965)$*]/,(when()what(),mul(393,927)@ what()how(),/mul(157,25)}%:who()-how(727,121)who()[mul(335,527)[%^,>/&where(){select(415,462)mul(450,651)@-where()when()%&('mul(741,677)#what()-:? ;+when()?mul(783,55(!' <{who()when()#(mul(905,243),mul(822,319)>select()- )#why()'^+mul(837,766)^who(69,740);{,{}^?mul(495,650when()select()when()(%why()mul(298,908)?from()-where()mul(781,697)%<mul(802,337)how()who()mul(912,22)<how()]where()-+from()mul(769,224)/}]where()mul(727,470)#^)!@,don't()+/&why()]who()(&mul(653,780))@ <how())who()/<mul(246,377)( where()~when() :where()mul(189,554)(mul(902,862)from()%^what()how()%<where()$mul(542,480)(/?,%mul(413,772)#mul(63,506)((+{ ;*^@:mul(114,204)+@>)<what()what()]mul(245,578)~select()mul(320,125)*{ [:#how()<{+mul(406,999)mul(577,430)who()%! why()*&where()?don't()$@$what()who()who();>$[mul(661,538)<{-&<select()'}mul(200,315)mul(112,246)where()where(404,923)from()%+';<^$mul(122,413)select()what()mul(721,764)/}what()why()'$)!<mul(892,451)>%%&$-how(),,what()mul(634,148)[mul(13,464)*'?what()'$%mul(311,661)]?how()don't()[>^]%when()# where()what()mul(5,587)+!-what() +mul(618,897)#where()where())how()<mul(343,790)??->{mul(944,841)@'?<mul(954,120)/*from()&what()what()/~/mul(86,632)from()?;<$:mul(607,376) select()!%mul(47,177)}/~*mul(800,210):when()what()}who()why()why()$,how()do()-/who(),where()mul(113,797);]+from()^mul(819,538)what()~why();^when()where()don't()mul(267,315)-?who()>,(~~mul(970,389)*,')mul(285,941)^#mul(554,821),&}]/when()mul(906,954)who()why(),!!()why()mul(89,545)~;) why()*)mul(507,709)@mul(977,650)+]how()-, mul(204,198){/$'~}<{]}do())? +;/why()select()%*mul(226,790)< >how())from()$ ;#mul(901,307)?when()+when()when())mul(19,239)>where()(when() mul(964,735)from()mul(484,646)select() ,;@how()$');do()^#what()mul(297,515))#*{;</mul(491,320)(;+%')mul(675,449)$}*when()!}@mul(21,16)who()(from())[/*?'mul(263,684)~{{when()from()+mul(751,630)[(?mul(445,676)~~mul(840,40))+how()-~what()mul(298,977)from()>%&~select()mul(404,614))~)[mul(182,657),{from()mul(450,272)(mul(228,343):what()[what()%(mul(970,721) #%> why()mul(879,558) %+?do()-)select()]mul(723,300); *why()mul(384,706)?)do()mul(799,503)~select(327,603)when()<>mul(216,403)select()<{(,mul(721,553)from())?when()mul(319,645)don't()*';how()where()(how(151,143)mul(675,236)<mul(242,159)*mul(532,562)mul(923,707)mul(13,834)&-where()
|
||||
@@ -0,0 +1,239 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
"strings"
|
||||
|
||||
aoc "go.sour.is/advent-of-code"
|
||||
)
|
||||
|
||||
// var log = aoc.Log
|
||||
|
||||
func main() { aoc.MustResult(aoc.RunnerReader(run)) }
|
||||
|
||||
type result struct {
|
||||
valuePT1 int
|
||||
valuePT2 int
|
||||
}
|
||||
|
||||
func (r result) String() string { return fmt.Sprintf("%#v", r) }
|
||||
|
||||
func run(read io.Reader) (*result, error) {
|
||||
sum := 0
|
||||
sum2 := 0
|
||||
|
||||
lexer := Lexer(read)
|
||||
active := true
|
||||
|
||||
for lexer.NextTok() {
|
||||
switch lexer.token {
|
||||
case "TokMUL":
|
||||
if m := readMul(lexer); m != 0 {
|
||||
sum += m
|
||||
if active {
|
||||
sum2 += m
|
||||
}
|
||||
}
|
||||
case "TokDONT":
|
||||
if readDont(lexer) {
|
||||
active = false
|
||||
}
|
||||
|
||||
case "TokDO":
|
||||
if readDo(lexer) {
|
||||
active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &result{sum, sum2}, nil
|
||||
}
|
||||
|
||||
func Lexer(in io.Reader) *lexer {
|
||||
seq := func(yield func(rune) bool) {
|
||||
buf := make([]byte, 256)
|
||||
s, _ := in.Read(buf)
|
||||
buf = buf[:s]
|
||||
|
||||
for len(buf) > 0 {
|
||||
for _, r := range string(buf) {
|
||||
if !yield(r) {
|
||||
return
|
||||
}
|
||||
}
|
||||
s, _ := in.Read(buf)
|
||||
buf = buf[:s]
|
||||
}
|
||||
|
||||
for !yield(-1) {
|
||||
}
|
||||
}
|
||||
next, stop := iter.Pull(seq)
|
||||
lex := lexer{iter: next, stop: stop}
|
||||
lex.readRune()
|
||||
lex.readRune()
|
||||
return &lex
|
||||
}
|
||||
|
||||
type lexer struct {
|
||||
rune rune
|
||||
next rune
|
||||
|
||||
iter func() (rune, bool)
|
||||
stop func()
|
||||
|
||||
buf []rune
|
||||
token string
|
||||
literal []rune
|
||||
}
|
||||
|
||||
func (l *lexer) Stop() { l.stop() }
|
||||
|
||||
func (l *lexer) readRune() {
|
||||
if l.rune == -1 {
|
||||
return
|
||||
}
|
||||
if r, ok := l.iter(); ok {
|
||||
l.rune, l.next = l.next, r
|
||||
} else {
|
||||
l.rune, l.next = l.next, -1
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lexer) loadRune(tok string) {
|
||||
l.token = tok
|
||||
l.literal = append(l.literal, l.rune)
|
||||
l.readRune()
|
||||
}
|
||||
|
||||
func (l *lexer) loadNumber() {
|
||||
l.token = "TokNUMBER"
|
||||
for strings.ContainsRune("0123456789", l.rune) {
|
||||
l.literal = append(l.literal, l.rune)
|
||||
l.readRune()
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lexer) loadString(accept string) {
|
||||
l.token = "TokSTRING"
|
||||
for !(!strings.ContainsRune(accept, l.rune) || l.rune == 0 || l.rune == -1) {
|
||||
l.literal = append(l.literal, l.rune)
|
||||
l.readRune()
|
||||
}
|
||||
}
|
||||
|
||||
func (l *lexer) NextTok() bool {
|
||||
l.literal = l.literal[:0]
|
||||
|
||||
switch l.rune {
|
||||
case 'm':
|
||||
l.loadString("mul")
|
||||
l.token = "TokMUL"
|
||||
if string(l.literal) != "mul" {
|
||||
l.token = "TokILLEGAL"
|
||||
}
|
||||
return true
|
||||
case 'd':
|
||||
l.loadString("don't")
|
||||
switch string(l.literal) {
|
||||
case "don't":
|
||||
l.token = "TokDONT"
|
||||
case "do":
|
||||
l.token = "TokDO"
|
||||
default:
|
||||
l.token = "TokILLEGAL"
|
||||
}
|
||||
return true
|
||||
|
||||
case '(':
|
||||
l.loadRune("TokLPAREN")
|
||||
return true
|
||||
case ')':
|
||||
l.loadRune("TokRPAREN")
|
||||
return true
|
||||
case ',':
|
||||
l.loadRune("TokCOMMA")
|
||||
return true
|
||||
|
||||
case -1:
|
||||
l.loadRune("TokEOF")
|
||||
return false
|
||||
default:
|
||||
if '0' <= l.rune && l.rune <= '9' {
|
||||
l.loadNumber()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
l.loadRune("TokILLEGAL")
|
||||
return true
|
||||
}
|
||||
|
||||
func (l *lexer) Iter() iter.Seq2[string, string] {
|
||||
return func(yield func(string, string) bool) {
|
||||
for l.NextTok() {
|
||||
if !yield(l.token, string(l.literal)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readMul(lex *lexer) int {
|
||||
if lex.token != "TokMUL" || string(lex.literal) != "mul" {
|
||||
return 0
|
||||
}
|
||||
|
||||
var a, b = -1, -1
|
||||
if !lex.NextTok() || lex.token != "TokLPAREN" {
|
||||
return 0
|
||||
}
|
||||
|
||||
if !lex.NextTok() || lex.token != "TokNUMBER" {
|
||||
return 0
|
||||
}
|
||||
a = aoc.Atoi(string(lex.literal))
|
||||
|
||||
if !lex.NextTok() || lex.token != "TokCOMMA" {
|
||||
return 0
|
||||
}
|
||||
|
||||
if !lex.NextTok() || lex.token != "TokNUMBER" {
|
||||
return 0
|
||||
}
|
||||
b = aoc.Atoi(string(lex.literal))
|
||||
|
||||
if !lex.NextTok() || lex.token != "TokRPAREN" {
|
||||
return 0
|
||||
}
|
||||
return a * b
|
||||
}
|
||||
|
||||
func readDont(lex *lexer) bool {
|
||||
if lex.token != "TokDONT" || string(lex.literal) != "don't" {
|
||||
return false
|
||||
}
|
||||
if !lex.NextTok() || lex.token != "TokLPAREN" {
|
||||
return false
|
||||
}
|
||||
if !lex.NextTok() || lex.token != "TokRPAREN" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func readDo(lex *lexer) bool {
|
||||
if lex.token != "TokDO" || string(lex.literal) != "do" {
|
||||
return false
|
||||
}
|
||||
if !lex.NextTok() || lex.token != "TokLPAREN" {
|
||||
return false
|
||||
}
|
||||
if !lex.NextTok() || lex.token != "TokRPAREN" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/matryer/is"
|
||||
)
|
||||
|
||||
//go:embed example.txt
|
||||
var example []byte
|
||||
//go:embed example2.txt
|
||||
var example2 []byte
|
||||
|
||||
//go:embed input.txt
|
||||
var input []byte
|
||||
|
||||
func TestExample(t *testing.T) {
|
||||
is := is.New(t)
|
||||
|
||||
result, err := run(bytes.NewReader(example))
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.Equal(result.valuePT1, 161)
|
||||
|
||||
result, err = run(bytes.NewReader(example2))
|
||||
is.NoErr(err)
|
||||
is.Equal(result.valuePT1, 161)
|
||||
is.Equal(result.valuePT2, 48)
|
||||
}
|
||||
|
||||
func TestSolution(t *testing.T) {
|
||||
is := is.New(t)
|
||||
|
||||
result, err := run(bytes.NewReader(input))
|
||||
is.NoErr(err)
|
||||
|
||||
t.Log(result)
|
||||
is.True(result.valuePT1 < 186942148) // first attempt too high
|
||||
is.Equal(result.valuePT1, 184122457)
|
||||
is.Equal(result.valuePT2, 107862689)
|
||||
}
|
||||
+14
-2
@@ -1,6 +1,7 @@
|
||||
package aoc
|
||||
|
||||
import (
|
||||
"iter"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -17,8 +18,8 @@ func Repeat[T any](s T, i int) []T {
|
||||
return lis
|
||||
}
|
||||
|
||||
func Reduce[T, U any](fn func(int, T, U) U, u U, list ...T) U {
|
||||
for i, t := range list {
|
||||
func Reduce[T, U any](fn func(int, T, U) U, u U, list iter.Seq[T]) U {
|
||||
for i, t := range Enumerate(list) {
|
||||
u = fn(i, t, u)
|
||||
}
|
||||
return u
|
||||
@@ -54,3 +55,14 @@ func Pairwise[T any](arr []T) [][2]T {
|
||||
}
|
||||
return pairs
|
||||
}
|
||||
|
||||
func Enumerate[T any](arr iter.Seq[T]) iter.Seq2[int, T] {
|
||||
return func(yield func(int, T) bool) {
|
||||
i := 0
|
||||
for v := range arr {
|
||||
if !yield(i, v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -16,7 +17,7 @@ import (
|
||||
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
|
||||
var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
|
||||
|
||||
func Runner[R any, F func(*bufio.Scanner) (R, error)](run F) (R, error) {
|
||||
func runnerFile[R any, F func(*os.File) (R, error)]() *os.File {
|
||||
if len(os.Args) < 2 {
|
||||
Log("Usage:", filepath.Base(os.Args[0]), "FILE")
|
||||
os.Exit(22)
|
||||
@@ -57,16 +58,20 @@ func Runner[R any, F func(*bufio.Scanner) (R, error)](run F) (R, error) {
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
input, err := os.Open(inputFilename)
|
||||
if err != nil {
|
||||
Log(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
scan := bufio.NewScanner(input)
|
||||
return input
|
||||
}
|
||||
|
||||
return run(scan)
|
||||
func Runner[R any, F func(*bufio.Scanner) (R, error)](run F) (R, error) {
|
||||
return run(bufio.NewScanner(runnerFile[R]()))
|
||||
}
|
||||
func RunnerReader[R any, F func(io.Reader) (R, error)](run F) (R, error) {
|
||||
return run(runnerFile[R]())
|
||||
}
|
||||
|
||||
func MustResult[T any](result T, err error) {
|
||||
|
||||
Reference in new issue
Block a user