5 Commits
Author SHA1 Message Date
xuu 6a17669107 feat(aoc2024): complete day 3 part 2
Go Test / build (pull_request) Failing after 57s
2024-12-03 16:15:53 -07:00
xuu 127257c494 chore: state after where broken 2024-12-03 15:12:39 -07:00
xuu 7b9a71f84c chore: state before changes that were working 2024-12-03 15:11:33 -07:00
xuu 669e2cfb2c feat: add day 3 2024 (iter crashes on solution 2) 2024-12-03 14:51:54 -07:00
xuu 2274eca981 feat: add day 2 2024
Go Bump / bump (push) Failing after 6s
Go Test / build (push) Failing after 44s
2024-12-02 10:24:38 -07:00
10 changed files with 1438 additions and 4 deletions

No files matched your search

+6
View File
@@ -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
+1000
View File
@@ -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
+88
View File
@@ -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
}
+43
View File
@@ -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)
}
+1
View File
@@ -0,0 +1 @@
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
+1
View File
@@ -0,0 +1 @@
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))
+6
View File
@@ -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()
+239
View File
@@ -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
}
+45
View File
@@ -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)
}
+9 -4
View File
@@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"flag" "flag"
"fmt" "fmt"
"io"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@@ -16,7 +17,7 @@ import (
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`") var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
var memprofile = flag.String("memprofile", "", "write memory 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 { if len(os.Args) < 2 {
Log("Usage:", filepath.Base(os.Args[0]), "FILE") Log("Usage:", filepath.Base(os.Args[0]), "FILE")
os.Exit(22) 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) input, err := os.Open(inputFilename)
if err != nil { if err != nil {
Log(err) Log(err)
os.Exit(1) 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) { func MustResult[T any](result T, err error) {