Compare commits
55 Commits
iter
...
4dc6fb41f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dc6fb41f3 | |||
| 7ee762858c | |||
| 3775e36fad | |||
| 069788b2ee | |||
| 6d4cdcefe0 | |||
| de31fdf400 | |||
| 4045d014f4 | |||
| fdace1fa25 | |||
| bbfa622270 | |||
| 05dc0c0ecc | |||
| 49319f1e21 | |||
| c6ec085ba9 | |||
| 7e7154bc7d | |||
| c260afd7c6 | |||
| 5299f9f66e | |||
| 77cae3d106 | |||
| 93f918bee8 | |||
| a383f91683 | |||
| d0146e18d4 | |||
| 78063d8bf6 | |||
| 29778566a4 | |||
| f7ab64cc96 | |||
| c4cc8a1c42 | |||
| 1a7666783d | |||
| 63850f082b | |||
| 58d479b9a6 | |||
| c0d2cb38a8 | |||
| b41163030a | |||
| 1af8eab8c2 | |||
| 68d161f2f7 | |||
| 5dc51a050f | |||
| 3185eef130 | |||
| 32d13861d9 | |||
| 99c79f84fe | |||
| d3ded19a61 | |||
| 868901c566 | |||
| f02033811d | |||
| 69f84f4819 | |||
| 26be0fb699 | |||
| 991d1efc65 | |||
| 498e8ea206 | |||
| 7c01756821 | |||
| 8e076c1134 | |||
| 4172592120 | |||
| 99001d75b5 | |||
| ab1a4d6a4a | |||
| 89e6dfe8be | |||
| 60a4950f24 | |||
| 59f67f1c64 | |||
| 89d59a6546 | |||
| 354a64fd23 | |||
| 3e6d4e18e9 | |||
| 38979959e6 | |||
| c6194437c3 | |||
| 0ff14b83d3 |
194
2020/README.md
194
2020/README.md
@@ -1,49 +1,155 @@
|
||||
# Results
|
||||
|
||||
## Day 1
|
||||
```
|
||||
AOC 2020
|
||||
Day 1 - Part 1 - binary : 1006875
|
||||
generator: 12.539µs,
|
||||
runner: 373ns
|
||||
Advent of code 2020
|
||||
Day 1 - Part 1 - binary: 1006875
|
||||
generator: 21.838µs,
|
||||
runner: 1.773µs
|
||||
|
||||
Day 1 - Part 1 - linear : 1006875
|
||||
generator: 4.945µs,
|
||||
runner: 7.727µs
|
||||
Day 1 - Part 1 - linear: 1006875
|
||||
generator: 5.339µs,
|
||||
runner: 8.329µs
|
||||
|
||||
Day 1 - Part 1 - set : 1006875
|
||||
generator: 16.721µs,
|
||||
runner: 1.288µs
|
||||
Day 1 - Part 1 - set: 1006875
|
||||
generator: 18.303µs,
|
||||
runner: 1.392µs
|
||||
|
||||
Day 1 - Part 2: 165026160
|
||||
generator: 4.735µs,
|
||||
runner: 1.465477ms
|
||||
|
||||
Day 2 - Part 1: 640
|
||||
generator: 1.713032ms,
|
||||
runner: 123.609µs
|
||||
|
||||
Day 2 - Part 1 - handrolled: 640
|
||||
generator: 173.912µs,
|
||||
runner: 109.58µs
|
||||
|
||||
Day 2 - Part 2: 472
|
||||
generator: 1.475144ms,
|
||||
runner: 10.985µs
|
||||
|
||||
Day 3 - Part 1: 148
|
||||
generator: 38.406µs,
|
||||
runner: 2.797µs
|
||||
|
||||
Day 3 - Part 2: 727923200
|
||||
generator: 37.063µs,
|
||||
runner: 12.181µs
|
||||
|
||||
Day 4 - Part 1: 239
|
||||
generator: 372.532µs,
|
||||
runner: 1.922µs
|
||||
|
||||
Day 4 - Part 2: 188
|
||||
generator: 363.202µs,
|
||||
runner: 43.784µs
|
||||
|
||||
Day 5 - Part 1 - glenng: 989
|
||||
generator: 171ns,
|
||||
runner: 81.501µs
|
||||
|
||||
Day 5 - Part 1 - wathiede: 989
|
||||
generator: 85.614µs,
|
||||
runner: 459ns
|
||||
|
||||
Day 5 - Part 2 - wathiede: 548
|
||||
generator: 86.417µs,
|
||||
runner: 29.328µs
|
||||
|
||||
Day 6 - Part 1: 6930
|
||||
generator: 118ns,
|
||||
runner: 630.141µs
|
||||
|
||||
Day 6 - Part 2: 3585
|
||||
generator: 127ns,
|
||||
runner: 2.007135ms
|
||||
|
||||
Day 6 - Part 2 - faster: 3585
|
||||
generator: 129ns,
|
||||
runner: 1.095441ms
|
||||
|
||||
Day 7 - Part 1: 222
|
||||
generator: 1.109401ms,
|
||||
runner: 202.592µs
|
||||
|
||||
Day 7 - Part 2: 13264
|
||||
generator: 1.092186ms,
|
||||
runner: 5.447µs
|
||||
|
||||
Day 8 - Part 1: 1744
|
||||
generator: 143ns,
|
||||
runner: 47.289µs
|
||||
|
||||
Day 8 - Part 2: 1174
|
||||
generator: 111ns,
|
||||
runner: 150.1µs
|
||||
|
||||
Day 9 - Part 1: 1309761972
|
||||
generator: 27.284µs,
|
||||
runner: 37.991µs
|
||||
|
||||
Day 9 - Part 1 - sorted: 1309761972
|
||||
generator: 26.598µs,
|
||||
runner: 230.765µs
|
||||
|
||||
Day 9 - Part 2: 177989832
|
||||
generator: 28.558µs,
|
||||
runner: 124.417µs
|
||||
|
||||
Day 10 - Part 1: 1625
|
||||
generator: 6.835µs,
|
||||
runner: 421ns
|
||||
|
||||
Day 10 - Part 2: 3100448333024
|
||||
generator: 4.802µs,
|
||||
runner: 1.176µs
|
||||
|
||||
Day 11 - Part 1: 2338
|
||||
generator: 75.55µs,
|
||||
runner: 11.383128ms
|
||||
|
||||
Day 11 - Part 2: 2134
|
||||
generator: 58.641µs,
|
||||
runner: 49.994105ms
|
||||
|
||||
Day 12 - Part 1: 1838
|
||||
generator: 38.302µs,
|
||||
runner: 8.936µs
|
||||
|
||||
Day 12 - Part 2: 89936
|
||||
generator: 33.951µs,
|
||||
runner: 8.316µs
|
||||
|
||||
Day 13 - Part 1: 153
|
||||
generator: 2.04µs,
|
||||
runner: 205ns
|
||||
|
||||
Day 13 - Part 2: 471793476184394
|
||||
generator: 2.258µs,
|
||||
runner: 3.68µs
|
||||
|
||||
Day 14 - Part 1: 10717676595607
|
||||
generator: 93ns,
|
||||
runner: 89.201µs
|
||||
|
||||
Day 14 - Part 2: 3974538275659
|
||||
generator: 92ns,
|
||||
runner: 5.803116ms
|
||||
|
||||
Day 15 - Part 1: 929
|
||||
generator: 177ns,
|
||||
runner: 253.908µs
|
||||
|
||||
Day 15 - Part 2: 16671510
|
||||
generator: 114ns,
|
||||
runner: 2.423626128s
|
||||
|
||||
Day 16 - Part 1: 23115
|
||||
generator: 246.028µs,
|
||||
runner: 24.917µs
|
||||
|
||||
Day 16 - Part 2: 239727793813
|
||||
generator: 246.67µs,
|
||||
runner: 429.366µs
|
||||
|
||||
Day 1 - Part 2 : 165026160
|
||||
generator: 4.272µs,
|
||||
runner: 1.225545ms
|
||||
```
|
||||
|
||||
## Day 2
|
||||
```
|
||||
AOC 2020
|
||||
Day 2 - Part 1 : 640
|
||||
generator: 1.732103ms,
|
||||
runner: 100.802µs
|
||||
|
||||
Day 2 - Part 1 - handrolled : 640
|
||||
generator: 157.527µs,
|
||||
runner: 97.775µs
|
||||
|
||||
Day 2 - Part 2 : 472
|
||||
generator: 1.374162ms,
|
||||
runner: 10.461µs
|
||||
```
|
||||
|
||||
## Day 3
|
||||
```
|
||||
AOC 2020
|
||||
Day 3 - Part 1 : 148
|
||||
generator: 40.059µs,
|
||||
runner: 1.345µs
|
||||
|
||||
Day 3 - Part 2 : 727923200
|
||||
generator: 95.265µs,
|
||||
runner: 6.908µs
|
||||
```
|
||||
|
||||
89
2020/input/2020/day10.txt
Normal file
89
2020/input/2020/day10.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
67
|
||||
118
|
||||
90
|
||||
41
|
||||
105
|
||||
24
|
||||
137
|
||||
129
|
||||
124
|
||||
15
|
||||
59
|
||||
91
|
||||
94
|
||||
60
|
||||
108
|
||||
63
|
||||
112
|
||||
48
|
||||
62
|
||||
125
|
||||
68
|
||||
126
|
||||
131
|
||||
4
|
||||
1
|
||||
44
|
||||
77
|
||||
115
|
||||
75
|
||||
89
|
||||
7
|
||||
3
|
||||
82
|
||||
28
|
||||
97
|
||||
130
|
||||
104
|
||||
54
|
||||
40
|
||||
80
|
||||
76
|
||||
19
|
||||
136
|
||||
31
|
||||
98
|
||||
110
|
||||
133
|
||||
84
|
||||
2
|
||||
51
|
||||
18
|
||||
70
|
||||
12
|
||||
120
|
||||
47
|
||||
66
|
||||
27
|
||||
39
|
||||
109
|
||||
61
|
||||
34
|
||||
121
|
||||
38
|
||||
96
|
||||
30
|
||||
83
|
||||
69
|
||||
13
|
||||
81
|
||||
37
|
||||
119
|
||||
55
|
||||
20
|
||||
87
|
||||
95
|
||||
29
|
||||
88
|
||||
111
|
||||
45
|
||||
46
|
||||
14
|
||||
11
|
||||
8
|
||||
74
|
||||
101
|
||||
73
|
||||
56
|
||||
132
|
||||
23
|
||||
93
2020/input/2020/day11.txt
Normal file
93
2020/input/2020/day11.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
LLLL.LLLLL.LLLLLLLLLLLLLLLL.L.LLLLLL.LLLL..L.LLLLLLLL.LLLLLL.LLLL..LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLLLL.LLL.LLLLLLLLL.L..LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLL.LLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LL.LLLL.LL.LLLLLLLLLLLLLLLLLLLL
|
||||
LLL.LLLLLLLLLLL.LLLL.LLLLLLLLLL.LL.L.LLLLLLL.LLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLL.LLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLL.LLL.LLLL.LLLLLLLLLLL.LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
...L..LL.LL.LLL....L......L..L.....L.....L....L.LL.....LL..L.L...LL.L...LL..L.L...L.LL...L..LL..L.
|
||||
LLLLLLLLLLLLLLLLLL.L.LLLLLL.LLLLLLLL.LLLLL.L.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLL.LLLLL.LLLLLLLL.LLLLL
|
||||
LLLLLLLLL.LLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLL.
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLLLL.L.LLLL.L.LLLLL.L.LLLLLLLL.LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLL.LLLLLLLL
|
||||
LLLLLLL..L.LLLLLLLL..LLL.LL.LLLLLL.L.LLLLLLL.LLLLLLLL.LLLLLL.LLLLL.LL.LLLL.LLLLLLLL.LLLL.LLLLLLLLL
|
||||
...L..L.L.L......L....L.L..L...L.L..L.L...LL.LL....L...L........L.L.LLL....L..L..L...L.L..L..LL...
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.L.LLLLLL.LLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLL.L.LLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLL.L.LLLLLLLLLLLLLLL..LLLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLL.LLL.LL.LLLLLLLLL.LLLLL..LLLLLLLL.LLLLLLLLLLLLLLL..LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLL.LLLLLLLLLL
|
||||
.LLLLLLLLL.LL.LLLLLL.LLL.LLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LL.LLLLLLLLLLL
|
||||
LLLLL.LLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
.LLLLLLLLLLLLLLLLLLL.L.LLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLL..LL.LLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
L....LL.....L......LLL......L.LLL..L....L.L....L....LL.L.LL.LL........LL....L.L.L..LLLL.......L...
|
||||
LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLL.LLL.LLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
.LL..LL.LL.LLLLLLLLL.LL.LLLLLLLLLLLL.LLLLLLL.LLLLL.LLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LL.LLLLLL.LLLLL.LLLLLLL.L.LL.LLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLL..LLLLLLLL.LLLL.L.LLL.LLLLLLLLLLLL.LLLLLLLL.LLLLLL.LLLL..LLLLLLLLLL..LLLL.LLLLLLLLLLLLLL
|
||||
LLL.LLLLLL.LLLLLLLLL.LLLLLL.LLLLLLL..LLLLLLL..LLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
.LLLLLLLLLLLLLLLLLLL.LLLLLL.LL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLL.LL.LLL.LLLLLLLL.LLLLLLL.LLLLLLLL..LLL.L.LLLLL.LLLLLLL.LLLLLL...LLLLLLLLLLLLLL
|
||||
LLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLL.LLLL
|
||||
LLLL.LLLLL...LLLLLLLLLLL.LL.LLLLLLLL.LLLLLLL.LLLLLLLLLLLLLL..LLLLL.LLLLLLL..LLLLLLL.LLLLLLLLLLLLLL
|
||||
..L...LLL........LL....L.....L.....L..L..L.....L.L.LL...L......LLLLL.L.L...........L.LL.....LL...L
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.L.LLL.LLL.LLLLLL.LLLLLLLL.LLLLL.LLLLLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLL.LLL
|
||||
LLLLLLLLLLLLLLLL.LLLLLLLLLL.LLLLLLLLLLLLL.LL.LL.LLLLLLLLLLLL.LLLLL.LLLLLLLLLLLL.LL.LLL.LLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL...LLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLL.LL
|
||||
LLLLLLL.LL.LLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL..LLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
....L..L.L.LL..LLL..L....LL...L.L..LL.L......L...LLL.L.L.L.....L.......L......LL.....L..L.L..LL...
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLLLLLLLLLL.L
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLL.L.LLL.LLLL.LLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLL...LLLLLL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLLL.LLLLLLLLL..LLLLLLLLLLLLLLLLLL.LLLLLLL.LLLL.LLLLLLL.LLLLLLLL.LLL.LLLLLLLLLL
|
||||
LLLLLLLLLL.L.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLL.LLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLL.LLLLLLLLLL
|
||||
LL.LLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLL.LLL.LL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
..LL.LLL...LLL.....L.L.L......L......L........L.LL......LLL..LL..L..L.LLL..LL..LL.L.....L.LL....L.
|
||||
LLLLLLLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLLLLLL..LLLL.LLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLL.LL.LLLLLL.L.LLLLLLLLL.L.LLLLL.LL.L.LLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LL.LLLLL.LLLLLLLLLLL.LL
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLL.LLLLLLLLLL.LLLLL.LLL.LLL.LLLLL.LL.LLLLLLLLLLLLLL
|
||||
L..L..LL..LLL...L......L.....L...LL..L..L.....L.L...LL......L.L.LLL.L..L....L....L...L.L........LL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL..LLLLLLLLLLLLLL
|
||||
LLLLLL.LLL.LLLLLLLLL.LLLLLLLLLLLLLLL.L.LL.LLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLL
|
||||
L.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLL.L.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLL.LL.LL.LLLLLLLLL.LL.LL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLLL.LL.LLLLLLLLLLLLLL
|
||||
LL.LLLLLLLLLLLLLL.LL.LLLLLLLLLLLLLL..LLLLLLLLLL.LLL.L..LLLLL.LLLLL..LLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLL.LLLLLLLLLLLL.LLLLLLLL.LLL.LLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL..LLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLL.LLLLL.LL.LLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLL.LL.L.LLLLLLL.LLL.L.
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLLLLLL.LLL.LLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLLLLLL.L.LL.LLLLLLLLLL.LLL
|
||||
..L....L....L....L........L...L....L..LL.L.L..L.LLLL.L.LLL...L...L..LL..L...L....L....L.......L.L.
|
||||
LLLLLLLLLL..LLL.LLLLLLLLLLL.LLLLLLLL.LLL.LLL..LLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLL..LL..LLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LL.LLLLL.LLLLLL.LLLLLLLLLLLL..LLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLL.LLLLLLLLLLLLLLLLL..LLLLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLL.LLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLL..LLLLLLL..LLLLLL.LL.LLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLL.L
|
||||
L.LLLLLLLL.LLLLLLLLL.LL.LLL.LLLLLLLLLLLLLLL..LLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL..LLL.LLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLL.LLLLL..LLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
L.....L..LLL.....LL.L..L..LL....LLLLL.LL..L.......L...LL.....LL...L...........L.....L.L..L.....L.L
|
||||
LLLLLLLLLL.LLL.LLLLL.LLLLLL.LLLLLLLL.LLLLLLL.LLLLLLLLL.LLLL..LLL.LLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLLL
|
||||
LLLLLLLLLL..LLLLL.LL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLL.LLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLL.LLLLLLLL.LLLL.L.LLL.LLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLL.LL.LLLLLLLLLLLLLLL
|
||||
LLLLL.LLLL.LLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LLLL..LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLL..LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLL..LLLLLLLL.LLLLLLLLLLLLLL
|
||||
........LLLLLL.LL.L..L...L...LLL....L.......LLLL..L.LL.L..L.L.LLL...L...L.......L..L.....L.L.L..LL
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LL.LLL..LLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLLLLL.LLLLLLLLLLLLLLL..LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLL.LLLLLLLLLL
|
||||
L.LLLLL.LLLLLLLLLLLL.LLLLLL.LLLLLLLLLLL.LLLL.LLL.LLLLLLLLLLL.LLLLLLLLLLLLL.LLLLLLLL.LLLLL.LLLLLLLL
|
||||
LLLLLL.LLL.LLLLLLLLLLLLL.LLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLL.LLL.L.L.LLLLLLLL.LLLLLLLLLLLLLL
|
||||
LLL.LLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLL.LLLLL.LL.LLLLLLLLLLLLLLLLLLLLL.LLLLLLL..LLLLLLL.LLLLLLLLLLLLLL
|
||||
..LL..L....L.......L....L....LL...L.L..L.........LL..L..LL.L....LLL.L.LLL...L.....LL.....LL.LL....
|
||||
LLLLLLLLLL.LLLLLL.LL.LLLLLLLL..LLLLL.LLLLLLLLLLLLLLLL.LLLLLL.L.LLLLLLLLLLL.LLLLLLLL.LLLLLLLLLL.LLL
|
||||
L.LLLLLLLLLLLL.LLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLL.LL.LLLLLL.LLLLL.LLLLLLL.LLLLL.LLLLLLLLLL.LLLLLL
|
||||
LLLLLLLLLL.LLLLLLLLL.LLL.LL.LLLLLLLL.L.LLLLLLLLLLLLLLLLLLLLL.L.LLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLL.
|
||||
LLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLL
|
||||
LLLLL.LLLL.LLLLLLLLL.LLLLLL.LLLL.LLL..LLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLL.LLLLL.LLLLLLLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLLLLLLLLLLL.LLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLL.LLLL
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLL.L.LLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LL.LLLLLLLLLLL
|
||||
.L.L....L........L....LL...L...L...L..L.............LL.LL..L.L.L...LL.......LLL.......LLL.L.L.L..L
|
||||
LLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLLL.LL.LLLLLLLLLLLLLL.L.LLLLL..LLLLL.LLLLLLL.LLLLLLLL.LLLL.LLLLLLLLL
|
||||
LLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLLLLLLLLL.LLLLL.LLLLLLLL.LLLLLL.LLLLLLL
|
||||
LLLLLLLLLL..LLLLLLLL.LLLLLL..LLLLLLL.LLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLLL.LLLLLLLLLLLLL
|
||||
LLLLLLLLLL.L.LLLLLLL.LLLLLLLLLLLLLL.LLLLLLLL.LLL.LLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLL
|
||||
LLLLL.LLLLLLLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLL.L.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL.L.LLLLLLLLLLLL
|
||||
786
2020/input/2020/day12.txt
Normal file
786
2020/input/2020/day12.txt
Normal file
@@ -0,0 +1,786 @@
|
||||
N3
|
||||
F18
|
||||
L180
|
||||
F40
|
||||
N3
|
||||
R90
|
||||
S5
|
||||
R90
|
||||
N4
|
||||
F24
|
||||
R90
|
||||
E5
|
||||
F36
|
||||
R180
|
||||
W3
|
||||
W4
|
||||
F63
|
||||
N4
|
||||
W1
|
||||
N1
|
||||
E1
|
||||
L90
|
||||
W1
|
||||
N2
|
||||
E2
|
||||
S2
|
||||
F39
|
||||
W4
|
||||
S3
|
||||
F93
|
||||
N1
|
||||
F83
|
||||
S1
|
||||
R90
|
||||
W3
|
||||
R90
|
||||
W4
|
||||
L90
|
||||
F53
|
||||
S4
|
||||
F4
|
||||
L90
|
||||
W3
|
||||
F83
|
||||
L180
|
||||
W2
|
||||
L90
|
||||
W2
|
||||
L90
|
||||
W1
|
||||
N3
|
||||
F63
|
||||
R90
|
||||
N2
|
||||
N3
|
||||
E4
|
||||
F10
|
||||
S3
|
||||
E4
|
||||
R90
|
||||
F11
|
||||
L90
|
||||
R90
|
||||
S2
|
||||
W2
|
||||
F100
|
||||
W5
|
||||
R270
|
||||
F40
|
||||
S5
|
||||
L90
|
||||
E2
|
||||
L90
|
||||
E2
|
||||
L180
|
||||
N5
|
||||
F81
|
||||
N4
|
||||
E4
|
||||
L180
|
||||
F38
|
||||
W2
|
||||
F22
|
||||
W5
|
||||
N5
|
||||
E1
|
||||
N2
|
||||
W4
|
||||
N2
|
||||
F68
|
||||
N1
|
||||
F2
|
||||
S1
|
||||
F47
|
||||
W5
|
||||
F80
|
||||
N3
|
||||
E3
|
||||
S2
|
||||
L180
|
||||
F87
|
||||
L180
|
||||
E4
|
||||
L90
|
||||
E2
|
||||
S3
|
||||
L180
|
||||
E2
|
||||
L90
|
||||
W2
|
||||
N4
|
||||
F21
|
||||
S4
|
||||
W5
|
||||
F70
|
||||
F4
|
||||
N2
|
||||
F14
|
||||
E2
|
||||
S3
|
||||
R90
|
||||
W3
|
||||
N2
|
||||
E3
|
||||
S1
|
||||
F85
|
||||
R90
|
||||
E1
|
||||
F80
|
||||
L90
|
||||
F100
|
||||
R90
|
||||
W1
|
||||
R180
|
||||
S4
|
||||
F58
|
||||
L90
|
||||
N3
|
||||
R90
|
||||
E1
|
||||
F42
|
||||
E3
|
||||
F93
|
||||
S3
|
||||
R90
|
||||
W2
|
||||
N3
|
||||
L90
|
||||
W3
|
||||
W2
|
||||
N2
|
||||
W1
|
||||
S4
|
||||
R180
|
||||
N5
|
||||
R180
|
||||
F52
|
||||
N5
|
||||
F20
|
||||
L180
|
||||
E5
|
||||
R90
|
||||
W2
|
||||
S4
|
||||
E1
|
||||
S3
|
||||
F75
|
||||
R90
|
||||
F49
|
||||
L180
|
||||
N3
|
||||
F31
|
||||
S3
|
||||
E3
|
||||
S5
|
||||
L180
|
||||
N3
|
||||
E2
|
||||
R270
|
||||
W5
|
||||
N3
|
||||
W5
|
||||
N3
|
||||
L270
|
||||
F54
|
||||
R90
|
||||
W5
|
||||
F73
|
||||
S3
|
||||
W2
|
||||
R90
|
||||
N2
|
||||
R90
|
||||
S5
|
||||
R90
|
||||
W4
|
||||
S2
|
||||
L90
|
||||
F3
|
||||
S2
|
||||
R90
|
||||
F76
|
||||
S3
|
||||
F56
|
||||
L90
|
||||
F5
|
||||
N1
|
||||
R180
|
||||
E3
|
||||
N2
|
||||
F20
|
||||
E2
|
||||
L180
|
||||
F38
|
||||
R180
|
||||
W4
|
||||
R90
|
||||
S3
|
||||
N5
|
||||
E5
|
||||
F26
|
||||
S2
|
||||
L180
|
||||
E4
|
||||
R90
|
||||
F52
|
||||
N3
|
||||
L90
|
||||
N5
|
||||
E4
|
||||
F63
|
||||
L90
|
||||
F48
|
||||
W5
|
||||
F29
|
||||
N1
|
||||
E3
|
||||
L90
|
||||
N5
|
||||
L90
|
||||
S3
|
||||
F8
|
||||
N2
|
||||
R90
|
||||
E4
|
||||
S2
|
||||
E2
|
||||
F10
|
||||
W2
|
||||
L90
|
||||
N2
|
||||
R90
|
||||
F2
|
||||
E2
|
||||
N4
|
||||
R90
|
||||
F74
|
||||
W3
|
||||
W5
|
||||
S2
|
||||
R90
|
||||
N3
|
||||
L90
|
||||
E3
|
||||
F58
|
||||
N4
|
||||
E5
|
||||
S4
|
||||
E3
|
||||
F72
|
||||
L180
|
||||
E3
|
||||
S2
|
||||
L90
|
||||
W4
|
||||
S1
|
||||
F14
|
||||
W1
|
||||
N1
|
||||
E3
|
||||
W4
|
||||
L90
|
||||
N1
|
||||
F97
|
||||
R90
|
||||
N4
|
||||
E3
|
||||
F95
|
||||
F95
|
||||
L90
|
||||
S4
|
||||
F55
|
||||
R90
|
||||
W2
|
||||
N1
|
||||
R90
|
||||
F16
|
||||
L90
|
||||
S5
|
||||
F4
|
||||
R90
|
||||
F24
|
||||
S4
|
||||
E2
|
||||
R90
|
||||
W5
|
||||
E1
|
||||
L270
|
||||
F12
|
||||
L90
|
||||
F100
|
||||
W1
|
||||
S5
|
||||
W2
|
||||
S3
|
||||
F95
|
||||
L90
|
||||
F44
|
||||
N5
|
||||
F79
|
||||
S4
|
||||
R180
|
||||
E2
|
||||
S1
|
||||
F40
|
||||
R90
|
||||
W2
|
||||
R90
|
||||
F67
|
||||
S5
|
||||
F15
|
||||
L90
|
||||
N4
|
||||
L90
|
||||
S5
|
||||
E1
|
||||
R90
|
||||
N3
|
||||
W5
|
||||
N4
|
||||
L270
|
||||
F61
|
||||
L90
|
||||
E1
|
||||
L90
|
||||
E1
|
||||
F38
|
||||
E2
|
||||
F19
|
||||
W2
|
||||
L90
|
||||
S4
|
||||
R180
|
||||
W4
|
||||
F59
|
||||
N1
|
||||
F26
|
||||
N1
|
||||
W5
|
||||
F7
|
||||
N4
|
||||
F72
|
||||
E2
|
||||
R90
|
||||
F59
|
||||
N1
|
||||
F58
|
||||
N5
|
||||
F13
|
||||
N2
|
||||
F2
|
||||
S2
|
||||
W1
|
||||
F85
|
||||
R270
|
||||
S2
|
||||
F17
|
||||
R90
|
||||
F96
|
||||
S2
|
||||
L90
|
||||
E1
|
||||
N4
|
||||
F9
|
||||
R270
|
||||
F58
|
||||
N1
|
||||
L90
|
||||
W2
|
||||
S2
|
||||
F73
|
||||
W1
|
||||
S2
|
||||
F20
|
||||
E2
|
||||
S4
|
||||
F94
|
||||
L180
|
||||
F27
|
||||
S2
|
||||
F48
|
||||
N1
|
||||
L270
|
||||
S2
|
||||
F77
|
||||
E3
|
||||
F10
|
||||
W3
|
||||
L270
|
||||
S4
|
||||
F53
|
||||
F66
|
||||
E5
|
||||
S2
|
||||
F33
|
||||
S5
|
||||
L90
|
||||
W3
|
||||
S3
|
||||
E3
|
||||
R90
|
||||
E1
|
||||
F62
|
||||
S1
|
||||
L90
|
||||
S3
|
||||
E3
|
||||
N1
|
||||
S1
|
||||
E5
|
||||
S2
|
||||
F66
|
||||
N4
|
||||
N1
|
||||
W4
|
||||
F84
|
||||
R180
|
||||
F23
|
||||
F20
|
||||
E1
|
||||
S3
|
||||
R90
|
||||
E2
|
||||
F48
|
||||
F89
|
||||
L90
|
||||
F97
|
||||
R180
|
||||
N3
|
||||
F62
|
||||
L90
|
||||
N5
|
||||
F28
|
||||
W5
|
||||
N4
|
||||
L180
|
||||
N4
|
||||
W1
|
||||
N3
|
||||
L90
|
||||
F95
|
||||
N1
|
||||
W5
|
||||
R180
|
||||
N5
|
||||
F34
|
||||
S1
|
||||
W2
|
||||
N4
|
||||
F3
|
||||
S2
|
||||
E1
|
||||
R90
|
||||
E2
|
||||
F36
|
||||
S4
|
||||
E5
|
||||
F42
|
||||
W1
|
||||
L180
|
||||
S1
|
||||
F74
|
||||
F38
|
||||
N4
|
||||
R270
|
||||
N3
|
||||
W2
|
||||
S4
|
||||
L180
|
||||
F26
|
||||
S4
|
||||
F51
|
||||
R90
|
||||
F83
|
||||
R90
|
||||
F9
|
||||
S2
|
||||
W1
|
||||
F99
|
||||
S4
|
||||
W1
|
||||
F84
|
||||
W1
|
||||
R180
|
||||
F59
|
||||
W5
|
||||
R90
|
||||
F75
|
||||
S1
|
||||
F34
|
||||
E4
|
||||
N3
|
||||
L90
|
||||
F43
|
||||
W5
|
||||
N1
|
||||
R90
|
||||
F59
|
||||
W1
|
||||
N3
|
||||
W4
|
||||
S2
|
||||
F36
|
||||
N5
|
||||
W4
|
||||
E2
|
||||
F96
|
||||
R180
|
||||
F44
|
||||
R90
|
||||
F12
|
||||
E5
|
||||
F24
|
||||
W3
|
||||
F39
|
||||
S2
|
||||
L180
|
||||
W3
|
||||
W4
|
||||
F70
|
||||
N4
|
||||
E4
|
||||
F36
|
||||
E2
|
||||
N1
|
||||
F30
|
||||
L90
|
||||
S2
|
||||
F81
|
||||
R270
|
||||
R90
|
||||
F66
|
||||
W1
|
||||
L90
|
||||
W2
|
||||
F98
|
||||
S1
|
||||
E1
|
||||
L90
|
||||
E3
|
||||
N2
|
||||
F100
|
||||
W3
|
||||
N3
|
||||
R90
|
||||
F88
|
||||
E4
|
||||
L180
|
||||
F52
|
||||
L90
|
||||
E4
|
||||
F76
|
||||
W2
|
||||
L90
|
||||
E3
|
||||
F72
|
||||
S3
|
||||
L180
|
||||
F12
|
||||
F34
|
||||
E5
|
||||
F90
|
||||
S5
|
||||
W5
|
||||
E1
|
||||
N5
|
||||
L180
|
||||
E5
|
||||
F84
|
||||
E5
|
||||
E3
|
||||
L90
|
||||
E3
|
||||
F14
|
||||
L90
|
||||
W3
|
||||
L90
|
||||
S1
|
||||
L90
|
||||
W2
|
||||
F54
|
||||
R90
|
||||
S2
|
||||
F73
|
||||
S4
|
||||
E1
|
||||
S1
|
||||
F55
|
||||
E5
|
||||
N4
|
||||
R180
|
||||
L180
|
||||
N4
|
||||
R90
|
||||
F91
|
||||
L180
|
||||
F5
|
||||
E2
|
||||
N1
|
||||
W2
|
||||
F27
|
||||
W2
|
||||
S5
|
||||
R90
|
||||
S3
|
||||
F39
|
||||
S3
|
||||
W2
|
||||
F59
|
||||
F83
|
||||
W3
|
||||
E3
|
||||
E4
|
||||
L90
|
||||
S1
|
||||
R90
|
||||
E4
|
||||
F81
|
||||
E4
|
||||
R90
|
||||
W5
|
||||
F74
|
||||
W3
|
||||
E3
|
||||
F30
|
||||
L180
|
||||
S2
|
||||
E3
|
||||
F33
|
||||
S3
|
||||
R90
|
||||
F22
|
||||
S5
|
||||
F97
|
||||
S1
|
||||
E2
|
||||
F50
|
||||
E2
|
||||
F19
|
||||
E3
|
||||
L90
|
||||
L90
|
||||
S5
|
||||
W3
|
||||
F80
|
||||
F33
|
||||
E1
|
||||
R90
|
||||
N3
|
||||
L90
|
||||
F70
|
||||
L180
|
||||
W4
|
||||
N2
|
||||
R180
|
||||
S2
|
||||
F38
|
||||
S3
|
||||
F7
|
||||
R90
|
||||
E1
|
||||
N5
|
||||
F86
|
||||
W4
|
||||
F49
|
||||
W4
|
||||
F51
|
||||
S4
|
||||
F47
|
||||
R90
|
||||
W3
|
||||
R180
|
||||
R180
|
||||
W1
|
||||
F98
|
||||
S1
|
||||
W3
|
||||
S4
|
||||
L90
|
||||
F76
|
||||
E1
|
||||
F76
|
||||
R180
|
||||
S4
|
||||
R180
|
||||
W3
|
||||
F26
|
||||
N5
|
||||
F35
|
||||
S2
|
||||
F94
|
||||
F24
|
||||
N2
|
||||
F45
|
||||
E1
|
||||
L90
|
||||
F32
|
||||
S1
|
||||
R180
|
||||
F78
|
||||
F84
|
||||
L90
|
||||
N2
|
||||
F42
|
||||
R90
|
||||
F72
|
||||
S1
|
||||
E3
|
||||
N2
|
||||
W1
|
||||
F23
|
||||
E2
|
||||
F69
|
||||
L90
|
||||
F29
|
||||
R90
|
||||
S5
|
||||
W5
|
||||
L90
|
||||
W1
|
||||
S2
|
||||
E1
|
||||
F96
|
||||
S5
|
||||
R180
|
||||
F26
|
||||
S5
|
||||
W1
|
||||
S3
|
||||
F38
|
||||
S1
|
||||
E2
|
||||
S5
|
||||
W2
|
||||
S5
|
||||
F52
|
||||
L90
|
||||
F11
|
||||
E3
|
||||
R90
|
||||
E4
|
||||
F6
|
||||
L90
|
||||
R90
|
||||
W1
|
||||
R90
|
||||
E3
|
||||
F1
|
||||
E4
|
||||
N3
|
||||
E5
|
||||
R90
|
||||
N2
|
||||
R180
|
||||
W2
|
||||
N5
|
||||
F46
|
||||
N3
|
||||
E5
|
||||
F83
|
||||
R90
|
||||
F42
|
||||
S3
|
||||
R90
|
||||
N5
|
||||
F10
|
||||
2
2020/input/2020/day13.txt
Normal file
2
2020/input/2020/day13.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
1000390
|
||||
13,x,x,41,x,x,x,x,x,x,x,x,x,997,x,x,x,x,x,x,x,23,x,x,x,x,x,x,x,x,x,x,19,x,x,x,x,x,x,x,x,x,29,x,619,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,17
|
||||
577
2020/input/2020/day14.txt
Normal file
577
2020/input/2020/day14.txt
Normal file
@@ -0,0 +1,577 @@
|
||||
mask = 00101X10011X0X111110010X010011X10101
|
||||
mem[41248] = 4595332
|
||||
mem[26450] = 60
|
||||
mem[32210] = 982366
|
||||
mem[1060] = 234632920
|
||||
mem[20694] = 38159
|
||||
mem[45046] = 58906955
|
||||
mask = 010110010X1101XX11X0100001X0000X00X1
|
||||
mem[16069] = 7758
|
||||
mem[55864] = 2473265
|
||||
mem[37095] = 103513009
|
||||
mem[4911] = 1002
|
||||
mem[63231] = 6932274
|
||||
mem[21265] = 72322159
|
||||
mem[43724] = 16591353
|
||||
mask = 01001X01X101011101010101011X1X000000
|
||||
mem[63470] = 30339812
|
||||
mem[16920] = 471738
|
||||
mem[1014] = 29735753
|
||||
mem[61061] = 6866
|
||||
mem[8437] = 9138168
|
||||
mem[46487] = 1819945
|
||||
mem[2985] = 15040783
|
||||
mask = 0X10X1101111001X1X100X1X00011100XX11
|
||||
mem[32836] = 12902
|
||||
mem[60365] = 24782
|
||||
mem[29953] = 10085
|
||||
mem[18214] = 1160
|
||||
mask = 001011X10X11100000100X0X0X0X01011001
|
||||
mem[39434] = 37383633
|
||||
mem[278] = 670174555
|
||||
mem[34062] = 20749996
|
||||
mem[2583] = 6222093
|
||||
mask = 01X111X1001101X11110100XX001X1000XX1
|
||||
mem[6075] = 49890
|
||||
mem[9363] = 2392780
|
||||
mem[24967] = 218861
|
||||
mask = X110111X1XX1010101111X01XX1000X001X1
|
||||
mem[41334] = 11836
|
||||
mem[24242] = 7263066
|
||||
mem[17289] = 64986060
|
||||
mem[2583] = 4702503
|
||||
mem[21650] = 103905
|
||||
mem[134] = 486675
|
||||
mask = 00X010100110XXXX111000XXX1000011000X
|
||||
mem[45307] = 37940
|
||||
mem[16597] = 224911
|
||||
mem[17943] = 392744
|
||||
mem[55001] = 622484
|
||||
mem[35954] = 470
|
||||
mask = 11X01011X11000X1X1100X100X011101X011
|
||||
mem[1005] = 56755
|
||||
mem[16146] = 4333571
|
||||
mem[32347] = 10486693
|
||||
mem[11452] = 377363
|
||||
mem[25158] = 328161913
|
||||
mem[51956] = 250388
|
||||
mem[10044] = 34078606
|
||||
mask = 011011X1X111010111110000X001X1X00110
|
||||
mem[8773] = 10575925
|
||||
mem[33116] = 175
|
||||
mem[36101] = 14593
|
||||
mask = 0100010X110X0101010XX10X011111XX1101
|
||||
mem[21083] = 1922
|
||||
mem[3653] = 912
|
||||
mem[26768] = 7321934
|
||||
mem[49134] = 17616
|
||||
mem[62950] = 41565481
|
||||
mem[12957] = 2136786
|
||||
mem[10324] = 17788
|
||||
mask = X11X0X0X11010101110X01111010X1100X11
|
||||
mem[5462] = 18755
|
||||
mem[39408] = 2435211
|
||||
mem[49271] = 6589
|
||||
mask = X1X011XX01X100010110001X0X0X111X1100
|
||||
mem[52570] = 2166
|
||||
mem[28731] = 16573421
|
||||
mem[18265] = 1192
|
||||
mem[22435] = 10856992
|
||||
mem[19263] = 7550
|
||||
mem[30541] = 434738
|
||||
mem[36101] = 869138
|
||||
mask = 010001X001010001XX010100000010110X01
|
||||
mem[52893] = 125505223
|
||||
mem[22919] = 597
|
||||
mem[62950] = 54107
|
||||
mem[52797] = 7649588
|
||||
mem[30421] = 3968
|
||||
mem[30429] = 614720
|
||||
mask = 01X0X10001X100010X1011XX00000X111X00
|
||||
mem[44718] = 11141064
|
||||
mem[42713] = 206218234
|
||||
mem[51781] = 527553473
|
||||
mem[1967] = 27527823
|
||||
mem[6386] = 5404
|
||||
mask = 00101X10XX11X0XX1110001000001110X11X
|
||||
mem[62339] = 72046594
|
||||
mem[14657] = 3243652
|
||||
mem[750] = 40239
|
||||
mem[134] = 1936539
|
||||
mem[5775] = 266384125
|
||||
mask = 011X111XXX110X01X11X000X00010100011X
|
||||
mem[2956] = 438895
|
||||
mem[41520] = 7282
|
||||
mem[42192] = 34769
|
||||
mem[8837] = 2587
|
||||
mask = 01XX11100101000X0X10011XX01010011101
|
||||
mem[12515] = 450388
|
||||
mem[62175] = 649233
|
||||
mem[54743] = 129273
|
||||
mem[10284] = 159823
|
||||
mem[31311] = 16983
|
||||
mem[56137] = 852771967
|
||||
mask = 11010X1X01010101X1010X11101111X00010
|
||||
mem[47190] = 526627409
|
||||
mem[34299] = 540572
|
||||
mem[61226] = 61426238
|
||||
mem[12892] = 61446
|
||||
mem[33421] = 4192
|
||||
mask = 0110111111X10101111010100XX01XX10100
|
||||
mem[41685] = 258
|
||||
mem[26983] = 60795579
|
||||
mem[28064] = 10483
|
||||
mem[33070] = 66557269
|
||||
mem[12624] = 448724
|
||||
mem[38125] = 141175913
|
||||
mask = 010X1X00X101000X0111010101XX01011000
|
||||
mem[12957] = 7693971
|
||||
mem[45285] = 4628
|
||||
mem[48546] = 799
|
||||
mem[17857] = 7578026
|
||||
mask = 00101X100101X0010110000000XX1010X110
|
||||
mem[41841] = 234511
|
||||
mem[27387] = 2990
|
||||
mem[24636] = 1269957
|
||||
mem[15638] = 428392
|
||||
mem[22064] = 272
|
||||
mask = 0XXX10X01011X011111000000XX0X100X010
|
||||
mem[26764] = 482715793
|
||||
mem[8422] = 70439
|
||||
mem[17857] = 28381730
|
||||
mem[4524] = 750659820
|
||||
mask = 11101100010100X1011000111000XX00X010
|
||||
mem[52570] = 517468200
|
||||
mem[25263] = 11113122
|
||||
mem[33421] = 32762600
|
||||
mask = 11101X01XX1000010X10111000X1101X0X00
|
||||
mem[16577] = 910
|
||||
mem[32450] = 16924479
|
||||
mem[4421] = 24801362
|
||||
mem[46638] = 8546454
|
||||
mask = 01X11X1101110101X1X1X010000XX101X001
|
||||
mem[34209] = 24703796
|
||||
mem[30481] = 831
|
||||
mem[46487] = 147322
|
||||
mem[38619] = 11686
|
||||
mem[26615] = 1174
|
||||
mask = 010X0X00110100X1XX000010110XX100X001
|
||||
mem[53587] = 198046
|
||||
mem[38420] = 22334
|
||||
mem[20181] = 962
|
||||
mask = XX101101X01000010XX01111001111010100
|
||||
mem[33812] = 107321
|
||||
mem[8613] = 7395
|
||||
mem[1117] = 149990
|
||||
mem[22919] = 23596
|
||||
mask = 1X01110110010X01X100000001111011X010
|
||||
mem[57800] = 254591077
|
||||
mem[6633] = 60308580
|
||||
mem[8980] = 104196938
|
||||
mem[5936] = 289911936
|
||||
mem[44806] = 297364592
|
||||
mask = 11X10XX0X1010X01010110XXX01111100X00
|
||||
mem[49271] = 177794
|
||||
mem[15368] = 259266583
|
||||
mem[19327] = 590
|
||||
mem[40243] = 24245
|
||||
mem[57130] = 1201404
|
||||
mem[22545] = 1831196
|
||||
mem[59161] = 25210381
|
||||
mask = 0X101X11111X010111100X110XX11000X10X
|
||||
mem[38749] = 2091454
|
||||
mem[45138] = 621877
|
||||
mem[52107] = 3430339
|
||||
mask = 0010X110X11X00101X100011XX111X000100
|
||||
mem[17228] = 252642
|
||||
mem[23892] = 13721
|
||||
mem[43787] = 2786942
|
||||
mem[55481] = 58875
|
||||
mem[513] = 892
|
||||
mem[62445] = 40312
|
||||
mask = 0010X11XXX11001011X01010X0111110X100
|
||||
mem[17415] = 7415167
|
||||
mem[9048] = 46059
|
||||
mem[2159] = 636711036
|
||||
mask = X010111X111X010X1110X10100XX1000X00X
|
||||
mem[38420] = 104527
|
||||
mem[24790] = 85
|
||||
mem[58634] = 127952377
|
||||
mem[8958] = 11672057
|
||||
mask = X01X111X00X110XX0X10000000000X0X0100
|
||||
mem[283] = 241
|
||||
mem[8898] = 36719
|
||||
mem[49134] = 217820
|
||||
mem[31884] = 419937
|
||||
mask = 0XX11110X1110X0101111000000100110X00
|
||||
mem[27694] = 6848
|
||||
mem[25843] = 331711
|
||||
mem[6688] = 581239
|
||||
mem[41591] = 171
|
||||
mask = 0100X100X1010X01010X001XX01XX1010101
|
||||
mem[30429] = 1103121
|
||||
mem[42192] = 7844667
|
||||
mem[21668] = 51727200
|
||||
mask = 001X1X10001X101XX1100X1000101100X010
|
||||
mem[4322] = 157863993
|
||||
mem[49962] = 9140
|
||||
mem[16964] = 1599
|
||||
mem[14443] = 2038
|
||||
mem[3767] = 16636129
|
||||
mem[13476] = 485497191
|
||||
mem[1663] = 163345
|
||||
mask = X101110111010101X1X10011001X10110000
|
||||
mem[13172] = 195
|
||||
mem[33921] = 5684133
|
||||
mem[1337] = 51317
|
||||
mask = X1XXX101110101X1010X0100XX111X101001
|
||||
mem[63928] = 4636
|
||||
mem[56436] = 3887978
|
||||
mem[6185] = 3037
|
||||
mem[7095] = 11521156
|
||||
mem[1663] = 121401
|
||||
mem[7218] = 20750
|
||||
mask = 010001001X0101010X00001XXX100XX10100
|
||||
mem[24149] = 309519
|
||||
mem[16287] = 12731276
|
||||
mem[29772] = 65227
|
||||
mem[37172] = 2824
|
||||
mem[17508] = 59271
|
||||
mem[22133] = 3806
|
||||
mask = 01X0X101011X000X0X101000100011111101
|
||||
mem[14401] = 158547520
|
||||
mem[37172] = 16841
|
||||
mem[40439] = 461272566
|
||||
mem[60909] = 478018315
|
||||
mem[43219] = 2154608
|
||||
mem[25369] = 46117
|
||||
mem[54852] = 79656
|
||||
mask = XX10111001X100X1X1100X1X0001110001X1
|
||||
mem[4213] = 900609324
|
||||
mem[19327] = 28071
|
||||
mem[30421] = 782
|
||||
mem[4804] = 17293
|
||||
mask = 0100X1000101X0010X010101X01000011001
|
||||
mem[18139] = 1546181
|
||||
mem[14021] = 33793814
|
||||
mem[46699] = 2014
|
||||
mem[51956] = 171606030
|
||||
mem[29702] = 475302805
|
||||
mem[18265] = 198549
|
||||
mask = 0101X0110X1X0101X1X1X01101001X001XX1
|
||||
mem[38962] = 132592128
|
||||
mem[9436] = 7464578
|
||||
mem[12650] = 49333
|
||||
mem[8837] = 3234578
|
||||
mask = 011X11101011X101111000XX001110001110
|
||||
mem[61694] = 1206
|
||||
mem[32263] = 20761769
|
||||
mem[2116] = 193628
|
||||
mem[13505] = 123039
|
||||
mem[62164] = 14323289
|
||||
mask = 1X101010100X0101X1110X01000101X00100
|
||||
mem[21385] = 1022949
|
||||
mem[51318] = 5667643
|
||||
mem[17420] = 36980027
|
||||
mem[29202] = 801
|
||||
mask = 0101X01XX11X0101X10110X1010001001001
|
||||
mem[15338] = 23103863
|
||||
mem[10488] = 4521
|
||||
mem[13172] = 17055515
|
||||
mask = X10111X11X01X111X100000000111011X111
|
||||
mem[36577] = 397263
|
||||
mem[8992] = 11944917
|
||||
mem[22064] = 738796
|
||||
mem[17310] = 1562710
|
||||
mem[30068] = 4950154
|
||||
mask = 011111X10111X10X010X00X1X100X0010001
|
||||
mem[31166] = 6551
|
||||
mem[62218] = 1528
|
||||
mem[11467] = 35999360
|
||||
mem[39578] = 11530695
|
||||
mem[30855] = 27864
|
||||
mem[18369] = 1610323
|
||||
mem[58953] = 12938251
|
||||
mask = 01X111010X1111X0010X0XX010000X000111
|
||||
mem[15411] = 1096
|
||||
mem[49541] = 3181
|
||||
mem[23568] = 276408
|
||||
mem[45168] = 1721
|
||||
mem[11394] = 155136
|
||||
mask = 1111X1X011010001X101010X100XX11001X1
|
||||
mem[61945] = 26647548
|
||||
mem[63262] = 110741
|
||||
mem[33783] = 158
|
||||
mem[12753] = 200460
|
||||
mem[43229] = 7579
|
||||
mem[37084] = 26507
|
||||
mask = 0100110011X10101010X00X01X11X1X10101
|
||||
mem[65089] = 636807464
|
||||
mem[5775] = 4440830
|
||||
mem[52107] = 69328099
|
||||
mem[38420] = 859060126
|
||||
mem[21272] = 1700
|
||||
mem[12062] = 176162
|
||||
mem[12094] = 8733
|
||||
mask = X100010111XX01X1X1010100X01101001X1X
|
||||
mem[44718] = 33650499
|
||||
mem[26507] = 165784650
|
||||
mem[12622] = 2023
|
||||
mem[5651] = 120398699
|
||||
mask = 110001011X010X0111X10X00011110001X00
|
||||
mem[44975] = 666498
|
||||
mem[11614] = 751
|
||||
mem[61354] = 5063
|
||||
mem[4396] = 1131
|
||||
mem[25418] = 882
|
||||
mem[49245] = 64151
|
||||
mask = 011X1X110111X1XX11X1100X01000X101001
|
||||
mem[59013] = 1141214
|
||||
mem[18016] = 95668408
|
||||
mem[30067] = 18132964
|
||||
mem[38900] = 286972459
|
||||
mem[42265] = 13529062
|
||||
mem[59369] = 6028326
|
||||
mask = 0110110X010100010XXX0X00X0011X101X1X
|
||||
mem[6479] = 8816055
|
||||
mem[28451] = 29446
|
||||
mem[61417] = 59156
|
||||
mem[6694] = 15597
|
||||
mem[29264] = 115437
|
||||
mask = 11110100110101011101XX0001X1X1110101
|
||||
mem[46886] = 114630
|
||||
mem[17383] = 452299
|
||||
mask = 010X110X11X10101000X001X011010000100
|
||||
mem[19215] = 487176198
|
||||
mem[59629] = 2120284
|
||||
mem[27009] = 3064
|
||||
mem[42335] = 22072
|
||||
mem[514] = 2010
|
||||
mask = 0100X1001101010X010000X0001000X00100
|
||||
mem[37232] = 2564
|
||||
mem[20561] = 29506163
|
||||
mem[27396] = 380700410
|
||||
mem[34075] = 868
|
||||
mem[24967] = 1882926
|
||||
mask = 010X1X01XX110111111X0XX0000X010X0101
|
||||
mem[61084] = 3068852
|
||||
mem[33028] = 188720342
|
||||
mem[17375] = 62850
|
||||
mask = X10X1X0X110101010X01001001101000X000
|
||||
mem[24149] = 1815
|
||||
mem[51489] = 197928369
|
||||
mem[27694] = 231814
|
||||
mem[11813] = 1002177793
|
||||
mem[526] = 104755102
|
||||
mem[22216] = 8396
|
||||
mask = 0110111101010001X1X0X11100X010001111
|
||||
mem[21083] = 2509191
|
||||
mem[13215] = 172339241
|
||||
mem[12386] = 106305632
|
||||
mask = X1X101X11101010101000X010X11101101X1
|
||||
mem[35709] = 64980388
|
||||
mem[51838] = 62510
|
||||
mem[48641] = 1174272
|
||||
mem[42157] = 149
|
||||
mask = 0X101100010100010X0X00X1100101111111
|
||||
mem[35807] = 1100541
|
||||
mem[10044] = 69616152
|
||||
mem[3047] = 142725213
|
||||
mask = 11101X1X10X101010111X001XX10X0X00100
|
||||
mem[38049] = 110
|
||||
mem[43097] = 14955394
|
||||
mem[61810] = 3545867
|
||||
mem[61238] = 5370
|
||||
mem[20585] = 191903
|
||||
mem[26133] = 24248
|
||||
mask = 010X110X011X00010110010100X0XXX1X011
|
||||
mem[15950] = 140910
|
||||
mem[12062] = 424527462
|
||||
mem[11876] = 236
|
||||
mem[5182] = 4776
|
||||
mem[50278] = 490
|
||||
mask = 010XX011011101X1110101110111110110X0
|
||||
mem[53736] = 2314
|
||||
mem[12633] = 5053
|
||||
mem[66] = 49557761
|
||||
mask = 01X01101X10101010101000X00111110100X
|
||||
mem[18849] = 911
|
||||
mem[20666] = 12891678
|
||||
mem[5609] = 10432
|
||||
mem[59720] = 22145720
|
||||
mem[17508] = 42631
|
||||
mem[8585] = 3448
|
||||
mask = 11X1X10X110101X101010X01X0011011X001
|
||||
mem[30601] = 9140827
|
||||
mem[30361] = 4166366
|
||||
mem[46057] = 16057
|
||||
mem[26983] = 251682577
|
||||
mem[63197] = 1603252
|
||||
mem[52893] = 462048575
|
||||
mask = 011011100111X00X11100X00100010001XXX
|
||||
mem[17534] = 25807901
|
||||
mem[4932] = 106350673
|
||||
mem[42192] = 735653575
|
||||
mem[10874] = 59007
|
||||
mask = 01000101110001X1XX001000001X1X011111
|
||||
mem[48049] = 386
|
||||
mem[1538] = 138451275
|
||||
mem[50333] = 15707
|
||||
mask = 0101100X01110111XX1X0000001011001X01
|
||||
mem[18139] = 102960
|
||||
mem[41277] = 5837
|
||||
mem[44484] = 29937
|
||||
mask = 11101XX10X1X0001011000100X010010X00X
|
||||
mem[30615] = 95201946
|
||||
mem[719] = 3697022
|
||||
mem[27391] = 150969140
|
||||
mem[62680] = 427952
|
||||
mem[7349] = 46922
|
||||
mem[17375] = 41348888
|
||||
mem[57800] = 1901
|
||||
mask = 0010X11X1X11X011111X0011001X01001111
|
||||
mem[46994] = 118757653
|
||||
mem[32947] = 23571
|
||||
mem[8653] = 1364
|
||||
mem[3767] = 6954112
|
||||
mask = 01001X0011010X000111X0X0X1X011011XXX
|
||||
mem[37908] = 88438829
|
||||
mem[20630] = 618075182
|
||||
mem[21520] = 101250753
|
||||
mem[10703] = 475904
|
||||
mask = 001001101XX10010111X1X10100111XX11X1
|
||||
mem[17310] = 2889476
|
||||
mem[2725] = 463419
|
||||
mem[65001] = 910330085
|
||||
mask = X1011011X111010101X110X1X1X0010110X0
|
||||
mem[15999] = 18586203
|
||||
mem[12825] = 51333145
|
||||
mem[29966] = 596120517
|
||||
mem[26866] = 141039
|
||||
mem[24223] = 415414
|
||||
mem[24403] = 16110598
|
||||
mask = 0XX00X01111X01110X011010101X01101010
|
||||
mem[43382] = 150995
|
||||
mem[28011] = 1021785
|
||||
mem[60339] = 7805893
|
||||
mem[37197] = 268431
|
||||
mem[17792] = 253366088
|
||||
mem[21437] = 24057926
|
||||
mask = XX1011X111100X00111X1100010111010011
|
||||
mem[18006] = 265940517
|
||||
mem[55921] = 1634
|
||||
mem[27656] = 17058
|
||||
mem[4911] = 3686
|
||||
mem[33243] = 8125794
|
||||
mem[47537] = 146165365
|
||||
mask = 110111011X01X1X10100X000010110111X0X
|
||||
mem[5775] = 176470
|
||||
mem[63017] = 24003454
|
||||
mask = 00011X001X11XX11111X01101010X0000010
|
||||
mem[1604] = 174349
|
||||
mem[42888] = 7159712
|
||||
mem[26615] = 1487
|
||||
mask = 01X11101100111111X000X1001110001011X
|
||||
mem[5344] = 8563500
|
||||
mem[21234] = 166162105
|
||||
mem[48935] = 10849963
|
||||
mask = 01000101XX0001111000XX0000X010010X00
|
||||
mem[24149] = 127627213
|
||||
mem[27338] = 43164114
|
||||
mem[47215] = 252815
|
||||
mem[47431] = 32732410
|
||||
mask = 01011100000100011X0X0XX101X111111100
|
||||
mem[13412] = 4193068
|
||||
mem[45046] = 148
|
||||
mem[63535] = 11659
|
||||
mem[6518] = 471308933
|
||||
mask = 111X111011X1X1X101111X000100001101X1
|
||||
mem[31114] = 118512878
|
||||
mem[41334] = 1604
|
||||
mem[7338] = 571
|
||||
mem[6001] = 4126415
|
||||
mem[5215] = 4392
|
||||
mem[47836] = 1862
|
||||
mem[22064] = 30804845
|
||||
mask = 0111010X11X1010X0101X1110011101X0111
|
||||
mem[13321] = 22426593
|
||||
mem[37095] = 5357
|
||||
mem[44281] = 467020
|
||||
mem[62680] = 2721559
|
||||
mask = 010001X0010100XX10010000011000101X00
|
||||
mem[30615] = 261491
|
||||
mem[31097] = 46202501
|
||||
mem[27880] = 6002395
|
||||
mem[51385] = 2780
|
||||
mem[51435] = 43181943
|
||||
mem[42192] = 107728750
|
||||
mask = 101011100X1100110X1X00X0101X10X11101
|
||||
mem[48366] = 859523
|
||||
mem[14111] = 859
|
||||
mem[21668] = 292390073
|
||||
mem[8073] = 858
|
||||
mem[12920] = 662378
|
||||
mask = X111X10011X10101X10101XX01111011X101
|
||||
mem[20630] = 4051571
|
||||
mem[55963] = 367
|
||||
mem[379] = 10962356
|
||||
mem[33028] = 37
|
||||
mem[24035] = 9459
|
||||
mem[50949] = 2030
|
||||
mask = 001011100X110X111X10101100011X010X11
|
||||
mem[8437] = 47226
|
||||
mem[41248] = 319
|
||||
mem[9624] = 3503
|
||||
mem[6875] = 5282
|
||||
mask = 11X111XX100101010100X01XX1X1001X1000
|
||||
mem[21292] = 1673693
|
||||
mem[51132] = 10346473
|
||||
mem[7504] = 4325
|
||||
mask = 111X010X1101011101X100010XX1X0111100
|
||||
mem[35415] = 6296
|
||||
mem[19215] = 1263591
|
||||
mem[49977] = 379136185
|
||||
mem[62950] = 28156510
|
||||
mem[8265] = 28662942
|
||||
mask = 01X110X01X1X0X11X1X00110000X01000100
|
||||
mem[54672] = 131784041
|
||||
mem[11394] = 24602
|
||||
mem[24646] = 10584
|
||||
mem[44349] = 4883
|
||||
mem[54743] = 2940969
|
||||
mem[8265] = 14841530
|
||||
mask = 0X10111X11100X0011X011XX00X011011010
|
||||
mem[49374] = 45910
|
||||
mem[25923] = 368017518
|
||||
mem[25114] = 8076340
|
||||
mem[62690] = 904875563
|
||||
mask = 010X11X0X1X1010X01010X01101001110101
|
||||
mem[39408] = 3080
|
||||
mem[6918] = 125955053
|
||||
mem[27880] = 29186
|
||||
mask = 01001101X101010X0101X1001111100010X1
|
||||
mem[11813] = 153838914
|
||||
mem[20585] = 1917
|
||||
mem[21385] = 1881773
|
||||
mem[8556] = 25758757
|
||||
mem[22435] = 802061
|
||||
mem[27631] = 13285866
|
||||
mask = 01101110111X0001011X10100X0100X10101
|
||||
mem[23441] = 186656612
|
||||
mem[2186] = 189388742
|
||||
mem[12866] = 874882
|
||||
mem[12947] = 23895
|
||||
mem[20630] = 77211
|
||||
mem[42083] = 63015239
|
||||
mem[51838] = 4984972
|
||||
mask = 00101110X111001X1X10001XX0X111XXX101
|
||||
mem[14789] = 244532376
|
||||
mem[21292] = 736136092
|
||||
mem[10874] = 513949
|
||||
mem[16755] = 12361
|
||||
mem[5416] = 22987
|
||||
mem[39578] = 106587
|
||||
mask = 010X11000X010001X1XXX0110011X1X1110X
|
||||
mem[43479] = 61
|
||||
mem[47199] = 15617564
|
||||
mem[18265] = 6027808
|
||||
1
2020/input/2020/day15.txt
Normal file
1
2020/input/2020/day15.txt
Normal file
@@ -0,0 +1 @@
|
||||
16,1,0,18,12,14,19
|
||||
265
2020/input/2020/day16.txt
Normal file
265
2020/input/2020/day16.txt
Normal file
@@ -0,0 +1,265 @@
|
||||
departure location: 35-796 or 811-953
|
||||
departure station: 25-224 or 248-952
|
||||
departure platform: 47-867 or 885-959
|
||||
departure track: 44-121 or 127-949
|
||||
departure date: 49-154 or 180-960
|
||||
departure time: 35-532 or 546-971
|
||||
arrival location: 41-700 or 706-953
|
||||
arrival station: 25-562 or 568-968
|
||||
arrival platform: 31-672 or 680-969
|
||||
arrival track: 43-836 or 852-961
|
||||
class: 38-291 or 304-968
|
||||
duration: 31-746 or 755-956
|
||||
price: 46-711 or 719-971
|
||||
route: 35-584 or 608-955
|
||||
row: 39-618 or 640-950
|
||||
seat: 25-308 or 334-954
|
||||
train: 26-901 or 913-957
|
||||
type: 33-130 or 142-965
|
||||
wagon: 34-395 or 405-962
|
||||
zone: 46-358 or 377-969
|
||||
|
||||
your ticket:
|
||||
97,103,89,191,73,79,83,101,151,71,149,53,181,59,61,67,113,109,107,127
|
||||
|
||||
nearby tickets:
|
||||
895,527,676,768,695,821,473,414,835,426,741,650,886,709,938,355,113,358,106,888
|
||||
559,796,709,661,116,680,773,857,118,304,704,578,720,339,584,914,270,196,661,861
|
||||
390,557,348,432,734,441,74,761,272,266,531,704,52,78,200,478,455,664,663,339
|
||||
400,386,926,211,100,481,358,429,450,336,943,549,933,78,274,722,571,483,144,442
|
||||
579,509,478,975,218,855,93,759,92,406,339,648,144,128,478,948,489,482,547,926
|
||||
512,946,469,183,24,694,889,198,551,947,275,857,408,943,734,382,308,80,448,119
|
||||
305,830,449,54,518,193,663,825,95,946,484,672,248,701,257,395,827,783,218,189
|
||||
128,52,773,150,561,436,483,913,526,819,903,700,530,941,757,509,386,885,554,788
|
||||
779,947,111,357,206,252,661,481,124,450,773,554,779,827,116,466,259,434,901,898
|
||||
651,143,274,523,89,53,116,71,513,108,753,858,209,282,410,436,357,57,517,743
|
||||
87,691,793,306,426,127,152,836,192,497,276,418,66,771,147,910,824,917,767,510
|
||||
180,657,454,609,60,190,705,337,941,947,835,554,546,84,546,772,389,193,531,890
|
||||
128,387,865,735,462,548,652,89,902,728,490,490,278,931,81,265,449,523,948,112
|
||||
588,892,450,651,154,583,667,835,356,497,81,405,671,480,53,259,514,896,352,734
|
||||
928,686,618,946,933,205,485,392,445,119,69,248,265,398,522,725,438,781,821,555
|
||||
73,213,183,89,210,650,349,356,722,550,341,816,986,824,250,145,890,446,690,698
|
||||
488,462,456,569,746,471,460,995,916,777,526,116,520,71,762,569,455,472,890,647
|
||||
549,351,421,477,661,335,148,530,759,207,599,283,304,208,271,609,919,574,528,708
|
||||
610,833,569,613,672,664,924,99,94,389,819,664,727,739,249,768,836,911,252,825
|
||||
923,429,814,577,109,818,571,522,714,646,815,706,898,439,216,494,495,931,898,458
|
||||
96,852,211,822,181,71,697,709,542,745,273,813,493,499,474,196,469,79,276,792
|
||||
608,219,527,665,474,755,419,700,913,644,822,393,666,412,335,402,281,618,460,771
|
||||
267,438,112,433,853,103,676,766,187,831,490,569,927,826,771,334,773,377,342,209
|
||||
258,98,457,900,83,511,612,897,220,414,119,24,734,572,147,425,72,509,118,287
|
||||
81,386,854,74,363,118,738,448,53,772,526,112,198,948,926,915,186,526,408,501
|
||||
853,553,490,194,282,756,261,939,754,448,386,522,516,83,154,65,433,780,415,451
|
||||
153,702,580,200,948,198,146,379,121,109,759,114,153,659,794,735,852,568,347,84
|
||||
856,742,770,91,270,611,693,148,450,265,506,889,680,657,130,729,75,457,455,8
|
||||
188,553,865,61,184,208,643,405,996,212,856,574,943,470,745,532,185,811,613,735
|
||||
887,381,24,68,426,640,89,85,693,757,460,109,913,689,763,358,121,655,498,424
|
||||
772,771,418,58,922,152,272,378,689,254,290,568,453,24,73,768,254,457,503,896
|
||||
695,649,924,79,209,661,775,859,575,221,858,86,269,857,836,305,274,23,659,795
|
||||
61,553,740,52,522,270,388,124,736,660,457,897,262,665,833,104,442,530,270,479
|
||||
392,893,306,252,278,336,259,560,421,103,150,409,923,460,190,711,261,503,12,924
|
||||
863,768,397,857,384,260,70,916,96,470,390,466,472,666,442,50,457,819,532,69
|
||||
861,441,900,519,383,467,809,191,72,426,720,711,380,468,505,485,546,266,743,652
|
||||
189,82,440,738,685,640,507,194,699,694,449,449,404,437,553,113,947,433,925,64
|
||||
151,768,503,66,918,129,913,474,827,823,358,115,750,833,791,783,576,790,920,276
|
||||
432,813,10,925,689,694,558,462,813,194,515,739,476,210,490,182,726,609,480,421
|
||||
148,211,56,811,945,213,550,354,465,529,463,795,58,655,677,919,282,266,812,357
|
||||
462,455,76,737,383,471,663,617,811,84,97,796,263,546,930,442,871,409,827,467
|
||||
250,724,682,652,197,512,501,861,373,220,276,899,734,777,258,467,888,287,697,441
|
||||
89,918,763,793,208,823,694,467,212,264,755,889,104,643,530,766,702,767,462,154
|
||||
146,347,79,341,791,195,858,622,648,833,796,390,189,262,192,249,719,392,67,95
|
||||
367,144,697,887,430,506,343,739,220,283,455,469,507,471,684,85,547,489,856,832
|
||||
498,65,97,187,445,427,615,583,451,198,734,513,142,454,756,713,513,612,471,789
|
||||
501,483,212,690,715,739,735,410,900,561,584,336,855,727,651,70,526,613,776,527
|
||||
654,762,519,185,350,438,584,940,831,687,378,782,278,436,716,816,502,63,217,835
|
||||
825,265,471,920,584,286,118,109,616,271,772,511,192,726,633,103,407,416,419,418
|
||||
223,263,121,56,187,654,514,737,876,942,856,286,427,768,831,740,455,281,85,854
|
||||
486,642,271,617,576,672,459,151,763,890,665,697,708,96,180,678,98,579,854,354
|
||||
78,219,92,736,143,865,268,862,658,120,356,732,704,854,147,411,214,685,117,926
|
||||
491,777,270,230,62,552,477,427,618,337,213,508,790,571,345,512,410,69,72,552
|
||||
697,149,409,661,576,615,696,142,942,353,281,736,473,452,739,452,418,367,866,583
|
||||
354,738,737,108,637,112,211,825,356,926,520,766,345,355,700,948,279,212,764,90
|
||||
203,425,771,222,279,428,583,507,277,689,687,215,188,864,467,72,674,641,381,759
|
||||
479,763,261,511,655,62,568,781,656,223,530,75,692,987,104,935,266,733,467,262
|
||||
415,111,785,308,489,111,932,648,455,512,218,55,910,285,389,355,497,520,547,724
|
||||
650,76,531,598,767,216,406,947,438,212,920,256,611,572,660,395,865,789,251,856
|
||||
498,740,14,822,82,335,522,724,932,414,284,775,722,191,699,493,421,740,475,184
|
||||
151,337,451,581,663,419,279,400,646,272,64,744,181,684,512,727,393,142,739,469
|
||||
251,649,640,621,76,858,305,440,923,264,407,642,520,687,258,827,108,947,78,932
|
||||
832,546,893,919,218,96,196,478,418,769,722,864,576,382,597,787,392,949,655,691
|
||||
83,741,429,56,289,615,546,734,127,450,638,192,343,251,498,255,852,308,671,923
|
||||
447,818,826,743,145,695,285,485,414,432,864,358,95,481,104,931,10,734,561,931
|
||||
784,502,263,204,449,94,766,941,684,464,124,776,425,86,608,380,272,467,485,282
|
||||
261,449,457,646,349,721,199,466,731,783,198,192,61,455,901,366,512,449,725,70
|
||||
449,145,579,783,501,426,111,736,277,257,433,864,455,217,289,600,128,642,573,51
|
||||
21,788,352,920,184,794,783,938,785,405,614,885,580,102,515,129,57,502,93,938
|
||||
578,664,726,192,224,484,761,452,105,436,556,240,765,671,273,249,920,663,896,858
|
||||
217,436,644,118,743,764,671,273,746,922,891,721,390,856,897,561,910,826,788,117
|
||||
507,618,859,708,149,687,922,181,119,350,671,391,457,980,727,554,786,788,386,441
|
||||
617,478,483,217,640,929,183,935,274,771,245,258,664,385,834,286,79,434,448,145
|
||||
428,946,524,413,402,51,496,115,777,682,64,378,681,493,520,609,147,77,900,692
|
||||
261,642,350,949,640,561,626,63,394,254,829,525,886,584,51,409,380,812,515,550
|
||||
282,66,827,524,274,514,830,356,703,818,721,862,532,447,405,614,901,949,334,561
|
||||
101,546,574,365,439,390,922,96,581,72,896,782,80,513,439,280,78,149,520,291
|
||||
183,854,86,307,796,500,150,103,358,725,368,937,191,211,900,644,732,742,198,142
|
||||
616,558,63,650,349,127,349,554,484,80,103,261,678,407,832,212,265,187,767,693
|
||||
441,943,943,730,689,980,471,183,348,289,948,820,641,469,569,666,914,438,575,609
|
||||
860,482,775,386,283,487,216,717,930,513,53,255,335,756,502,392,378,199,720,790
|
||||
781,656,555,584,206,284,519,490,890,463,679,272,289,776,559,408,343,206,572,486
|
||||
665,795,189,287,569,889,387,363,939,207,523,501,819,856,259,516,146,210,816,855
|
||||
857,78,94,277,821,336,715,663,760,184,934,460,424,528,511,478,780,892,214,738
|
||||
568,457,280,108,243,892,831,917,127,928,351,99,282,103,889,645,767,416,380,349
|
||||
933,760,991,736,661,127,853,682,756,180,291,216,83,825,935,651,146,113,498,813
|
||||
84,408,381,551,50,274,696,471,15,514,612,616,197,780,916,198,763,102,523,503
|
||||
584,416,85,180,931,485,900,761,674,358,915,502,103,938,946,614,728,290,471,892
|
||||
695,51,391,102,251,560,391,334,23,578,80,731,729,482,811,61,919,769,87,272
|
||||
827,143,548,613,933,986,813,513,664,283,796,860,268,933,493,568,444,391,383,855
|
||||
780,504,571,489,910,927,254,71,889,430,405,59,472,886,482,486,826,887,700,781
|
||||
60,341,248,187,998,265,128,338,506,65,698,664,741,186,284,711,277,867,550,559
|
||||
406,304,376,249,742,790,181,345,62,668,498,645,684,822,180,478,812,74,432,506
|
||||
270,381,831,187,680,283,241,608,735,496,130,724,530,892,792,81,419,772,655,351
|
||||
482,106,781,656,336,736,64,737,192,357,264,663,185,709,988,383,191,443,217,97
|
||||
267,944,254,179,82,486,290,794,86,496,617,662,762,308,450,385,180,683,479,215
|
||||
926,406,626,860,422,897,710,735,693,82,520,561,180,268,252,651,922,250,554,251
|
||||
468,475,923,562,8,289,924,914,944,392,216,51,485,60,196,927,187,815,78,290
|
||||
61,855,766,451,864,361,271,105,153,927,338,939,475,788,60,939,104,212,546,900
|
||||
704,512,570,707,831,427,571,487,429,945,217,186,344,474,50,571,493,405,708,441
|
||||
388,867,405,398,740,196,147,451,470,546,460,128,98,77,405,776,285,510,824,153
|
||||
279,438,550,654,392,979,461,852,692,560,56,931,920,69,614,642,427,930,512,116
|
||||
116,78,490,214,275,494,488,550,397,435,206,144,461,898,947,901,688,557,482,51
|
||||
579,519,554,903,552,731,59,211,729,654,823,761,154,514,65,888,494,697,348,142
|
||||
68,129,412,83,870,932,154,643,730,786,659,352,835,681,524,433,658,436,261,347
|
||||
488,814,279,774,821,105,710,483,16,105,460,520,477,786,546,206,75,554,70,699
|
||||
652,515,670,211,289,611,348,896,926,199,691,282,718,349,291,104,209,201,823,692
|
||||
355,87,455,472,934,568,832,827,340,776,261,818,1,143,933,722,482,287,698,785
|
||||
449,557,357,270,94,463,647,885,853,701,61,59,761,923,578,611,424,729,920,81
|
||||
619,826,258,520,738,779,577,90,719,757,513,658,338,683,836,918,288,463,691,340
|
||||
646,128,424,440,87,709,788,391,305,308,381,188,746,78,794,386,636,813,500,270
|
||||
191,778,659,767,346,257,95,154,393,423,609,380,107,617,857,347,122,142,223,431
|
||||
516,71,889,922,407,522,870,736,777,147,394,118,818,689,358,344,470,207,526,761
|
||||
98,97,682,814,62,20,108,828,482,711,524,764,201,771,834,186,495,409,418,434
|
||||
287,305,54,611,337,489,771,537,816,683,517,465,304,220,515,770,467,572,148,666
|
||||
215,390,287,269,284,121,727,925,305,815,347,87,808,193,121,97,577,524,820,186
|
||||
266,213,87,854,580,489,764,57,275,250,538,338,547,307,269,121,143,106,115,183
|
||||
555,893,866,888,522,195,404,557,455,647,774,494,818,109,784,571,66,822,671,440
|
||||
658,555,105,338,505,661,573,740,127,508,56,667,642,449,658,111,120,398,255,60
|
||||
277,65,550,280,640,817,900,262,490,419,791,201,266,548,881,219,350,287,260,821
|
||||
494,478,573,415,928,70,821,231,394,121,383,562,666,440,664,77,474,348,380,820
|
||||
666,260,412,534,918,655,449,283,743,463,90,727,558,76,113,711,612,824,745,941
|
||||
898,815,783,816,94,289,69,222,480,201,108,640,580,522,205,117,468,715,127,781
|
||||
942,472,648,744,925,112,903,781,410,106,897,274,306,818,781,575,896,664,450,647
|
||||
407,390,945,269,818,584,616,96,642,185,813,127,900,830,708,475,221,888,366,650
|
||||
249,407,939,915,95,265,439,436,164,71,766,943,197,110,115,75,890,63,84,268
|
||||
277,82,617,513,128,334,114,549,621,284,653,709,818,104,836,478,892,181,113,205
|
||||
443,473,198,416,918,642,646,795,900,488,1,920,728,443,824,188,695,578,522,78
|
||||
80,443,451,573,181,518,592,735,688,110,919,143,387,64,142,411,193,252,643,919
|
||||
392,492,486,95,528,252,448,934,527,579,796,902,822,305,477,270,468,923,859,889
|
||||
643,356,190,830,863,153,76,91,932,457,691,880,344,775,108,512,512,286,61,769
|
||||
146,490,417,429,687,395,525,477,930,521,61,268,444,184,64,77,235,466,110,727
|
||||
461,582,343,666,825,188,84,941,886,107,382,129,487,660,261,173,192,72,53,913
|
||||
128,935,546,419,143,787,83,779,577,431,859,658,496,475,403,52,380,357,863,548
|
||||
472,900,916,942,777,776,433,659,422,357,53,826,204,182,19,686,575,796,509,532
|
||||
908,201,268,129,858,495,916,711,697,854,224,757,308,406,484,477,426,503,687,89
|
||||
794,628,392,180,822,508,555,787,57,202,568,387,507,937,185,916,575,514,103,91
|
||||
519,348,79,82,745,708,515,99,111,416,564,411,385,652,76,409,818,758,469,473
|
||||
489,121,342,573,488,439,504,435,519,919,62,265,764,690,927,622,788,348,823,556
|
||||
660,501,588,654,478,660,725,721,653,352,581,343,88,196,286,616,787,532,830,644
|
||||
766,525,582,471,947,198,501,89,104,900,745,685,362,455,249,211,389,812,506,113
|
||||
425,506,457,255,289,492,498,468,707,766,180,386,609,742,57,564,828,782,769,515
|
||||
275,363,148,699,351,525,812,767,67,932,87,551,308,866,112,188,304,440,431,392
|
||||
424,414,510,822,223,709,419,55,73,546,203,404,759,860,279,273,927,474,347,861
|
||||
505,439,783,384,765,719,58,415,353,778,418,674,147,433,794,93,945,823,411,70
|
||||
918,250,934,436,812,385,207,675,481,383,405,345,208,618,681,84,87,785,616,215
|
||||
264,94,350,861,116,502,155,946,578,938,391,187,96,666,491,927,653,260,220,429
|
||||
391,895,497,648,495,81,256,887,348,181,216,354,213,657,501,561,743,483,824,998
|
||||
938,854,791,777,740,100,767,862,648,432,942,104,562,93,670,216,650,6,220,526
|
||||
255,110,477,344,347,887,124,552,82,895,147,58,260,77,424,813,615,444,223,928
|
||||
925,691,345,895,708,388,860,249,563,119,503,928,865,97,498,492,202,426,661,117
|
||||
472,96,280,424,480,440,348,896,73,503,718,862,730,899,260,941,469,337,186,259
|
||||
708,646,6,220,482,700,202,918,889,337,831,130,656,890,921,766,530,210,66,381
|
||||
524,508,528,346,649,77,433,939,935,793,423,304,318,97,671,932,562,736,726,253
|
||||
145,215,651,721,675,819,206,696,723,111,216,512,385,285,928,726,709,495,437,666
|
||||
118,288,95,866,435,102,353,196,335,935,145,105,125,508,306,438,818,261,854,736
|
||||
656,529,742,807,189,416,856,290,414,933,88,572,348,473,925,104,831,186,281,665
|
||||
249,198,417,714,279,936,813,814,823,357,351,89,304,60,936,503,103,377,381,505
|
||||
787,933,280,527,492,704,405,252,468,785,305,457,431,193,378,521,896,283,422,741
|
||||
814,860,216,405,129,790,490,906,465,929,181,478,667,93,497,888,423,641,866,502
|
||||
834,521,429,529,388,792,477,216,440,683,739,251,831,360,770,650,51,337,727,205
|
||||
204,401,110,794,394,682,569,95,190,287,720,515,70,524,440,191,501,442,853,644
|
||||
186,259,509,476,664,687,865,420,186,220,480,651,229,933,153,765,497,546,471,580
|
||||
405,916,150,514,702,387,741,939,385,896,576,824,487,504,866,867,356,734,889,581
|
||||
734,358,829,735,548,142,437,388,331,773,455,182,152,336,459,489,483,79,581,470
|
||||
67,656,820,264,406,739,698,51,516,547,822,128,580,191,71,0,562,857,550,103
|
||||
513,490,822,982,934,763,555,194,145,789,99,917,380,253,504,388,344,420,75,180
|
||||
101,662,492,414,147,343,818,668,490,488,69,715,406,731,552,81,357,477,945,833
|
||||
495,931,719,384,274,145,366,98,501,356,654,437,507,898,248,406,387,556,757,381
|
||||
410,423,821,395,984,521,862,260,190,611,654,709,213,145,264,84,935,496,248,385
|
||||
494,94,549,59,784,488,435,685,191,769,181,143,213,441,918,7,90,446,514,734
|
||||
886,505,744,566,855,288,441,655,487,507,417,744,901,786,278,431,211,769,778,570
|
||||
85,812,930,667,610,117,735,881,706,414,65,857,289,287,758,109,556,891,103,84
|
||||
79,476,445,211,515,707,725,557,859,80,393,792,600,470,427,478,120,390,504,930
|
||||
552,896,73,618,449,447,692,818,662,887,338,820,690,185,406,553,586,643,335,75
|
||||
745,668,406,877,551,76,756,501,785,98,459,304,519,720,57,469,416,739,668,793
|
||||
276,834,581,258,764,557,184,760,186,859,857,175,939,924,578,759,866,349,681,287
|
||||
578,153,766,489,349,406,276,380,709,55,852,304,222,859,900,878,492,347,437,925
|
||||
579,665,790,901,416,929,75,914,940,205,814,354,196,681,909,432,652,265,651,194
|
||||
58,505,344,79,528,418,731,121,604,142,270,150,780,257,88,355,789,935,83,337
|
||||
455,419,391,189,187,497,687,531,130,129,400,856,206,276,260,273,727,696,571,769
|
||||
886,920,698,784,582,611,698,856,440,248,475,392,876,463,190,443,914,70,697,222
|
||||
91,205,353,920,477,475,153,672,948,573,485,270,665,480,63,222,784,473,457,993
|
||||
738,745,212,346,653,828,50,860,379,118,921,694,540,819,214,147,657,94,55,497
|
||||
793,17,194,925,150,350,755,554,508,252,527,289,55,253,694,509,769,102,59,118
|
||||
461,250,272,394,480,248,758,890,667,128,575,217,842,700,649,792,212,693,897,96
|
||||
926,928,558,452,588,515,289,459,221,481,913,60,465,61,143,580,415,744,442,685
|
||||
267,152,772,891,153,257,448,895,115,612,520,538,710,698,885,463,195,746,86,466
|
||||
776,89,497,277,344,684,573,414,194,455,667,626,127,523,271,283,340,446,471,784
|
||||
334,641,853,473,278,452,94,763,644,690,831,738,136,256,733,922,935,462,768,776
|
||||
249,142,256,97,75,562,458,828,865,680,444,361,644,464,930,423,789,84,688,419
|
||||
706,52,714,347,510,782,286,428,708,113,505,89,901,834,770,120,511,427,204,63
|
||||
86,62,501,468,64,885,105,641,214,825,453,560,388,764,79,123,690,413,380,487
|
||||
96,885,505,689,938,511,483,189,202,97,355,792,500,689,392,336,713,740,853,788
|
||||
531,89,925,122,261,479,923,864,816,106,568,453,692,518,556,929,709,78,928,790
|
||||
456,513,395,212,757,730,729,653,724,975,429,756,457,418,489,725,929,528,437,184
|
||||
947,854,154,255,95,70,724,682,226,94,423,187,641,616,252,105,885,558,658,695
|
||||
663,386,584,556,209,277,542,732,552,106,818,819,690,415,415,478,216,219,815,218
|
||||
272,743,99,339,74,647,72,488,577,353,89,426,91,745,823,135,782,757,773,57
|
||||
81,826,492,113,562,66,430,287,830,370,284,434,547,142,899,338,765,378,732,644
|
||||
644,350,490,929,901,816,942,69,493,257,118,695,858,713,79,222,500,343,116,608
|
||||
487,412,702,771,418,722,857,475,437,450,812,830,250,490,561,553,658,709,90,462
|
||||
550,60,90,145,429,203,991,509,94,283,500,608,468,892,460,617,916,277,857,474
|
||||
524,695,889,437,582,895,901,422,761,691,107,117,476,54,818,807,269,517,928,894
|
||||
507,715,776,831,120,385,338,415,377,95,579,445,696,785,91,696,274,568,307,415
|
||||
85,90,129,78,940,774,521,468,459,101,431,348,255,205,416,24,66,434,287,755
|
||||
897,937,896,507,895,657,932,858,819,890,471,430,994,681,410,420,925,498,280,940
|
||||
50,941,470,745,458,72,271,740,288,546,549,125,504,467,248,254,184,767,91,51
|
||||
575,461,649,149,54,762,925,613,741,584,408,922,738,305,377,703,433,410,755,81
|
||||
507,269,148,886,180,659,817,71,466,476,111,336,498,782,361,707,915,576,650,478
|
||||
764,475,57,763,925,88,515,555,803,641,351,414,271,548,121,657,719,467,860,473
|
||||
484,764,910,487,191,204,721,682,113,187,926,569,441,337,761,787,142,202,353,106
|
||||
714,437,468,562,811,198,443,420,118,610,743,923,666,643,513,743,934,354,433,357
|
||||
513,578,744,574,721,739,551,488,207,574,865,145,901,103,701,508,218,818,264,777
|
||||
684,572,186,679,944,776,78,105,947,212,937,424,857,412,929,787,532,186,260,812
|
||||
423,259,558,577,648,425,306,672,307,714,550,573,348,612,249,744,253,521,427,193
|
||||
270,273,474,746,531,836,269,443,471,433,100,732,625,510,654,557,894,420,688,248
|
||||
825,522,945,833,262,507,82,601,680,945,446,946,921,89,477,513,411,276,70,151
|
||||
472,664,80,343,277,669,268,224,59,791,347,342,128,934,645,741,375,379,687,185
|
||||
668,894,212,392,95,491,791,264,573,812,894,698,728,73,767,448,794,634,116,213
|
||||
885,52,940,305,788,558,447,705,744,526,557,571,549,777,690,886,393,392,377,518
|
||||
107,344,897,693,767,468,249,560,570,289,121,341,608,435,412,860,399,778,646,470
|
||||
429,351,515,87,726,888,523,650,418,464,803,200,666,56,813,829,670,816,192,657
|
||||
279,187,280,500,382,942,52,687,853,62,491,306,934,506,699,321,796,381,934,55
|
||||
69,772,786,783,722,222,759,358,265,853,710,445,567,920,770,645,936,224,80,733
|
||||
377,795,794,438,256,813,829,852,511,919,872,662,200,188,457,889,942,467,519,503
|
||||
437,96,211,829,931,335,347,811,409,700,736,20,119,525,395,338,930,474,734,486
|
||||
502,199,287,285,471,551,488,252,895,466,104,415,156,945,512,51,358,830,340,859
|
||||
129,340,461,772,670,686,812,386,438,744,662,590,532,811,577,143,641,888,308,934
|
||||
85,815,948,571,117,949,516,980,822,58,258,737,856,573,212,819,923,531,914,949
|
||||
945,531,934,344,917,692,343,281,291,288,164,811,697,899,897,187,928,266,285,852
|
||||
377,420,283,655,127,421,221,740,550,611,50,306,417,80,610,392,429,705,477,852
|
||||
116,211,852,422,484,933,215,215,760,202,349,789,440,685,615,536,149,616,729,568
|
||||
497,393,743,867,60,863,150,13,939,149,56,527,783,111,782,493,671,280,260,923
|
||||
742,284,811,708,148,710,925,265,734,413,384,731,992,689,467,784,103,886,259,73
|
||||
484,349,479,705,188,188,933,465,221,722,72,571,274,735,456,866,192,818,76,393
|
||||
942,998,248,914,272,380,380,924,461,61,291,392,154,709,420,574,813,493,786,511
|
||||
55,50,353,792,84,721,865,223,205,833,997,930,579,761,583,98,727,744,647,780
|
||||
766,82,280,201,943,695,516,898,68,143,682,205,387,780,433,230,744,200,690,936
|
||||
205,558,687,475,90,337,920,665,529,196,456,445,283,55,120,749,60,304,553,389
|
||||
8
2020/input/2020/day17.txt
Normal file
8
2020/input/2020/day17.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
##.#...#
|
||||
#..##...
|
||||
....#..#
|
||||
....####
|
||||
#.#....#
|
||||
###.#.#.
|
||||
.#.#.#..
|
||||
.#.....#
|
||||
372
2020/input/2020/day18.txt
Normal file
372
2020/input/2020/day18.txt
Normal file
@@ -0,0 +1,372 @@
|
||||
(7 * (3 + 8 + 8 + 7) + (6 + 8 * 2 + 5 + 2 * 6) * (5 + 2) * 9) + ((7 * 4 + 8) * 6 * 8 + 9) * 7 * 2 * 2
|
||||
6 * ((9 + 4) * (6 * 7 + 5 + 8 * 2))
|
||||
7 * 8 + 2 + 8 * (8 * 4) * (4 + 8)
|
||||
(9 + 3 + 2 * 5 * 8) + 9 + 5 * 2 * 5 * (6 * 6 * 4 + 6 * 9 * 3)
|
||||
6 * 6 * 4 * (6 + (3 * 9 * 2) + 9 + (4 + 7 + 7))
|
||||
7 * ((4 * 6 + 4 + 6 * 8 + 6) + (2 * 7 * 8 + 5 * 3 + 7) + (5 * 5 * 5 * 7) + 8 * 7)
|
||||
(8 + 9 * 7 * 9 + 6) + (7 + 5) + 6
|
||||
5 * (6 * (3 + 2 + 9)) + 8 + 3 + 5 * (4 + 3 * 8 * 8 * 6 * 2)
|
||||
4 + (3 + 4 * (4 + 9 + 3) * (4 * 8 * 4 * 9))
|
||||
4 * 4 * 6 * 2 + ((8 * 4 * 3 + 6) * 5) + 6
|
||||
(8 * (8 + 5 + 5 * 7) * 9 + 2 + 9) * 4 + 9 * ((3 + 3) + 8) + 9
|
||||
((9 + 8 * 3 + 2 + 9 + 8) * 3 + (3 + 7 * 6) * 9 * 2) + 3 * 7
|
||||
5 + 5 * (5 * (6 + 6 + 6 + 7) * 7 + (9 * 4) * 4 * (8 * 9))
|
||||
7 * (2 * 7 + 3 + 5 + 5 * 2) + 4 + 3 * 3 + 5
|
||||
(4 + 5 * (2 * 4 + 5 * 2 * 7 + 5) + 2 + 9) + 4 + 9 * 9 * 3
|
||||
7 * 6 + (6 * 2 + 4 + 5 * 8) + (6 * 2 * (4 * 7 * 2) + 9 * (5 * 2 * 4) + (3 + 2 * 5)) * 8
|
||||
2 + ((9 * 3 * 3 * 3) * (5 * 9 + 6 + 7 + 6 + 8) * 3)
|
||||
7 * ((9 + 7 + 4 * 3 * 4 + 4) + 4 * 3) * 5 * 3 * 7
|
||||
8 * (3 + 5 * 9 + 4) * 6 + 4
|
||||
7 + 6 * 7 * ((7 * 6 * 2) * 3) * 5 * 7
|
||||
8 + 5 * 4 * (3 + 5 * (8 + 5 * 2) + 6) + 6
|
||||
4 * 8 + ((3 * 5 * 4) + 7) + (4 * 2)
|
||||
((5 + 8 + 7 + 6 * 6 + 3) + 4 * 3 * (5 * 2) * 5 * (2 * 9)) + 6 + 3 * (2 * (2 + 4 + 8) * 4) + (9 + 3 + 6 * (9 + 5 * 6 * 3 * 8 * 5) + (4 * 6) + (6 * 3 + 2 + 8))
|
||||
(3 + 4 + 8) + 6 * (7 * 6 * (9 * 3 * 5 * 5 * 4 * 5) + (6 + 4) * (5 * 2 * 3 + 3) + (2 * 7)) + 2 * 4
|
||||
6 * (6 * 9 * (3 * 9) * 4 + 9) + 6
|
||||
4 + 6 * 7 * ((3 + 5 + 3) * (6 + 3 * 9 + 6 * 8 * 9) + 6 * 4) * 8
|
||||
5 + (6 + 9 * (7 * 8 * 8 * 3 * 4) + 2) * 4 * 2
|
||||
(2 * 7 * 6 + 9 + (3 * 6 + 4 * 7 + 5) + 8) + 7 + 7 * 8
|
||||
2 + (6 + 4 + (5 + 5) * 7) * 2 + 7 * 5
|
||||
4 + 9 * 3 + 8 * 6
|
||||
(5 + 5 + 9 * 8 * (4 * 5 + 6 + 3 * 8 * 3) + 6) + 9 + 9
|
||||
(8 * 4 * 7 + 9 + 6 * 9) * (9 + 2 * 2) + 3
|
||||
((9 * 4 + 8 + 4 * 2 + 2) * 3 + (6 + 9 * 5 * 4) * 4 + 6 * 5) * 5 * 3 * 5 + (3 + 5 * 4)
|
||||
5 + (5 * 3) * (2 + 8) * (3 + 6 + 4 * 6 + 7 + 7) * 5 * 7
|
||||
6 * 6 * 7 * (5 * 4 + 2 + 6 + (8 + 6 + 4 + 9 * 5))
|
||||
2 * 9 + (2 * (8 * 7 + 6 + 5 + 3) + 2 + 9 * (3 * 9 * 4 * 7 * 7 + 5) + 3) + (4 + 6 * 4 + 6)
|
||||
(9 + (8 * 8 + 2 + 2 * 6 + 6)) * 8 + 4 + 3 + (9 + 3 + 9 + 9 * 4 * 8) * 2
|
||||
8 * 4 * (4 * (3 + 7 * 7 + 3) + 8 * (5 + 2 + 3) * 2) + 9
|
||||
5 + (6 * (3 * 3 + 7 * 3) * (4 * 4) + 2 * 4 * 4)
|
||||
3 + (5 * 8 * 9 * 3 + 9 * (6 * 7)) * 9 + 3
|
||||
3 * (9 * 3 + (5 + 4 * 7 + 3 + 8)) + 4 * 2 * 3
|
||||
8 * 9 + 6 + (7 + 7 + 9 * 8 * 5 * 6) * 5
|
||||
(8 + 9 + 3 + 7 * 7) + 2 + 9 + (8 + 7 + 4 + 2) + 9
|
||||
4 * (2 * (7 * 4 + 2 + 9 + 6 + 7) + (4 + 2) * 3 + 9 + 6) + 6 * 4 + 7 * 5
|
||||
(3 * 4 + (5 * 8 * 2) * (7 + 8)) + 7 + 8 + 5 + ((6 * 9) * 4 * 5)
|
||||
4 + ((9 + 9) + (7 * 8 + 2 * 8 * 2) + 9) + 2 + 7 * 2
|
||||
8 * 3 * (9 + 5 + 8 + 5)
|
||||
4 + 4 + (6 + 2 * 7 + 9 + 6 * 5)
|
||||
((8 + 3 * 8 * 2) + 7 + 7 * (7 * 7 * 7 + 3) * 9 * (9 * 4 + 7)) + 4 + 6
|
||||
6 + (7 * 2 + 4 + 5 + 4) + 9 + ((7 * 9) * 7) * 5
|
||||
(7 * 3 * 2) * ((9 + 6 * 2 * 6 * 3) + (6 * 7) + 3 + (6 + 5 * 5 + 4 + 9 * 6) * 4 + 9) + 4 + 7 + 6
|
||||
9 * (3 * (9 + 8)) * 4
|
||||
6 * (4 * 2 * (9 * 5 * 4 + 7 + 9) + 6 + (3 + 6 * 2)) * 5 * (3 * (2 + 6 * 8 * 6 + 3 + 7) * 8 * 7 * (9 * 8 * 7 + 7 + 9) * 7) + 3 + 6
|
||||
7 + 3 * ((6 * 3 * 9) + 3 * 9)
|
||||
7 * ((4 + 4 * 4 * 9 * 7) + 2 * 9) * 8 * 6 * 6 + 3
|
||||
6 + 5 + (5 + 3 * (3 + 7 + 9 * 3) * 6) + 3 + ((2 * 3 * 4 + 4) * 6 + (3 + 3) + 2)
|
||||
9 + ((8 * 9 * 3 * 2) * 5 + 8)
|
||||
(2 + 7) * 3 * (8 + 5) + 9
|
||||
4 * (5 + 4 + 6 * (9 * 4 + 8 * 4 * 7 * 3) * (4 * 4 * 6) * (9 + 7 + 8 * 4)) * (4 + 4 + 9 + 8) + 7 * 8 + 5
|
||||
((7 * 4 * 4 * 3) * 4 + 2 * 2 + 2) * 9 + 9 * 8 + 9
|
||||
4 + 6 + 2 * (5 + 3 + 8 * 4)
|
||||
((7 + 6) + 3 * 3 * 5) * ((9 * 3 + 5 + 8) + (3 + 8 * 8 + 7 + 5 * 6) + 2 * 5 + (7 + 9 + 2)) + (4 * 2 * (5 + 8 + 5 + 3) * 5 + 6 * 2) + 6 * 5 * (2 * (9 + 4) * (7 * 8) * 8 + 7)
|
||||
6 + 5 + 5 + 2 * 5
|
||||
5 + 5 + 8 * 8 + 2 + 6
|
||||
(3 * (4 * 6 * 8 * 2)) + 3
|
||||
(5 + 6 * 3 + 5 * 2) * 5 * (3 * 5 + 2 * 7 * 9 * 3) + 5 * ((6 + 2 * 7 + 2 + 4 + 2) * 9 + 6) + 7
|
||||
(7 + 7 * 4 * 7) * ((8 * 5 * 9) + 6 * 9 + 3 * 3 * 9) * 8 * ((3 * 5 * 2 + 6 + 5) * 7 + (6 * 2 * 7 * 7) + 8 + 8 + 6)
|
||||
(3 * 6 + 7 + 6 + 3 + 7) * 4 * 7 * ((9 + 3 + 6) * 5 + 3 + (5 * 7 + 4 + 5 * 2) + 5) * 5 * 9
|
||||
7 * ((7 + 6 + 2 + 9) + 3 * 4 + 9 + 2 + 2) + 2
|
||||
3 * 8 * 2 * (6 * 2 * 2 + 4 * 8) + 8 + 7
|
||||
8 + 3 + ((4 * 6 * 5 * 7) * 9 + 9 + 8 * 4)
|
||||
(6 + 4 + (6 + 3 + 3 + 3) + 6) * 9
|
||||
2 * 6 * (5 + 2) * (6 * 6 + 7 + 2)
|
||||
4 + (8 + 2 + 4) * 4 * 5 + (9 * 5 + 9) + 8
|
||||
6 * 3 * 9 + 6 + (2 * 4 * 3 + 2 * 5 * 3) * 6
|
||||
2 + (8 + 5 * 7 + 4 + 7 * (2 + 9 * 6 * 5 * 3 + 3)) + 9 * 4
|
||||
(9 + (2 + 6 + 7 * 4 * 8) + 9 * 4 + 9) * 3 + 8 * 8
|
||||
2 * (9 * 5 * 9 + (8 * 9 + 5)) * 8 * 8
|
||||
3 + 6 + 2 * 3 * 9 + 9
|
||||
8 * 7 + 8 * (5 + 6) * 5 + 4
|
||||
4 * (6 * 2 * (3 + 6 * 3) + 7 * 5 + 6)
|
||||
(7 * 3 * 7 * 4 * 3 * 2) * (9 + 8 * 9) + 9 * (4 * 5 + 3 + 5 + 9)
|
||||
9 + 8 * 3 * 4 + (9 + 8 * 9) + (4 * (6 * 4 * 9 * 5 + 6 + 4) + 8 + 7 + (4 * 9))
|
||||
2 * (4 * (3 + 4 + 8 + 5) * 8 * 6)
|
||||
8 * (8 * 2 * 6 + 6 + 6) * 8
|
||||
(9 + 3 * 4 * 9 + 5 * 5) * 4
|
||||
(9 * 9 * 4 * 4 + (6 * 2) + (3 + 3 * 2)) + 3 + ((2 * 3 + 8 * 4 * 8 * 2) + 2 + 3)
|
||||
7 * (9 * (6 + 3 + 7)) * ((8 + 3 + 3 * 3 + 3 + 7) + 4 + 5 + 3 * (6 * 4 * 6 * 6 + 2 * 5) + (2 + 3 + 9 + 3 * 6 + 4)) + 6
|
||||
8 + 6 * (3 + 5 + 6 + 9) * 4
|
||||
(6 + 7 + 7 + 7 * 6 + 5) + 3 * 5 * 4 * 5 * 6
|
||||
(2 * 9 + 9 + 3 * 7 + 6) + 3 + 7 + 4 + 9
|
||||
(7 + (8 * 7 * 4 * 7 * 2 + 4) + (5 + 2 * 2 + 2 * 2 * 6)) * 3 * 4 + (4 * 2 + 4 * 6 + 3 * (8 * 6 + 4 * 3 * 7)) * 6
|
||||
2 * (3 * (5 * 7 * 8 * 7 + 8) + (6 * 3 + 5) + 5 + 9)
|
||||
8 * 4 + ((7 + 2 + 8) + (2 * 8 * 4 * 4 + 4 * 7) * 2) * 5 * 4
|
||||
2 * 6 * 2
|
||||
2 + (2 + 6 * 5 * 9) + ((8 + 2 * 6 * 5 * 5) * 7 + 3) + 3
|
||||
((9 + 4 + 6 * 3 + 9) * 5) * (7 * 2 * 7 * 5 * 2) + 7 + 9 + 7
|
||||
2 + 2 * 8 + 8
|
||||
4 + 6 + 4 * 7
|
||||
4 + 5 + 5 * 8 * (8 + 4 + (2 * 8 + 9 * 9 + 4 + 5))
|
||||
(7 + 2 + (8 * 4 * 2 + 9 * 6) * 4) * 2 + (9 * 2 * 8 * 9 * 4)
|
||||
4 + 9 + 6 * (4 * 6) + 7
|
||||
6 + 4 + 8 * (7 * 9 + 7)
|
||||
3 * 2 + 2 + 9 + (2 * 9 * 2 * 8 * 2 * (2 + 8 + 9 * 9 + 7)) * 7
|
||||
9 + 9 + 5
|
||||
(2 + 3 * 3) + 7
|
||||
(9 * 7 + (8 + 8 * 6) + 2 * 7 * 3) + 6 * (5 * (2 + 9 + 9 + 6) + 6) * 8 * (4 + 4 * 6 * 5 + 5) * 8
|
||||
7 + 4 + (4 * 2 + (2 * 7 + 2 + 4 + 2 + 5) + 9 * (9 * 7 + 7)) + 9 + 7 + (8 + 9 * 7 + 2 + (7 * 8 * 5 * 4 + 6 + 8))
|
||||
(8 * 3) * (9 + 2 * 7 * 7 + 7) * 6 * 8 + 8 + (9 + 9 + 3 * 5 + 3)
|
||||
4 * 5 + 2 + 4
|
||||
((7 + 3 * 8 + 3) * 8 + 4 + 4 * 4 + 8) * 5 + 9 * (3 * 9 + 8 * 7 * 9 * 4) + 7
|
||||
(8 + 6 + 7 + 9) + 8 * 6 * (5 + 2 + 3) * 8
|
||||
(9 * 8 * (6 * 5) + 9) + 4 + 8 + 8 * 8
|
||||
(4 + 5 * 9) * 7 + 7 * 6 + 8 * (2 + 5 * 8)
|
||||
(4 + 3 + (6 + 2 + 2 + 6 * 6 * 2) * 4 * 2 * 9) + 3
|
||||
8 * (5 + 8 + 2 * 7) + 2 + ((5 * 6 + 4 + 7 + 6 * 5) * 7 * 3 + 8)
|
||||
2 + 5 + (6 * 3 + 2) + 8
|
||||
2 + 9 * 6 * 5 + 5
|
||||
3 * 3 + 7
|
||||
(9 + 4 * 9) + 5 + (2 * 6 * (6 + 9) + 2 + 6) * 2 * ((9 * 6 + 7 * 3) + 5 * 2 + 3 * 9)
|
||||
2 + 6 + ((6 * 9 * 9 * 8 * 9) + 9) * (5 + 2 * 5 * (3 + 5 * 8 * 5 * 2 * 9) * 8) * ((7 + 9 + 3 + 6 + 5) * 4 * 5)
|
||||
3 * 9 * (5 + (3 * 4 * 2 + 8) + 5 * 3) + 4
|
||||
9 * (9 * 3 + 3 + 4 + 7 + 4) + 3
|
||||
2 * 9 + 3 * 9 + 5 + 9
|
||||
(6 + (6 * 6 * 6 + 7 + 7 + 5) * 5) + 3 + 4 * 9
|
||||
(2 * 8 * 8 * 6 * 8) + (5 + (5 * 6) * (8 + 5 + 7 * 7 + 2) + (6 * 4 + 7 + 5) + (3 + 5 + 8 + 6)) * 8 + ((8 * 3 + 3 * 7) * 4 + (3 * 8 * 4))
|
||||
4 + ((9 * 2 * 9 * 9 * 7 + 5) * 6) * 7 * 7 + 5 * 8
|
||||
(3 * 6 + 6 * (5 + 6 * 4 * 6 + 2 + 9)) * 9 * 9 + (2 * 7 * 2 * 5)
|
||||
6 + 2 + (8 + 6)
|
||||
6 + 3 * (3 + 3) + 8 * (9 * 6)
|
||||
(2 * 8 + 4 + 5) + 7
|
||||
7 + (2 * 9 * 5 * 6)
|
||||
2 + 9 + ((7 + 3 + 3 * 9) * 6 + (5 + 2 + 8 + 5 * 6) * 7 + 8)
|
||||
((4 + 9 + 8 * 6 + 8 * 9) + 8) * 6
|
||||
9 * (9 * 3 + (3 * 8 * 8 * 7) * (4 + 8) + 8 * (5 * 3 + 2 + 4 * 3))
|
||||
9 * (7 + (3 * 5 * 5 + 3 * 7)) + (5 * 3 + (4 * 7 * 7 + 8) * (3 * 7 * 5 * 6) * 8) * 5 + (2 * 7) * 4
|
||||
4 * ((2 + 3 * 2 * 2 + 3) + 4 * 4 * 4 * 5 + (3 + 3 * 9 * 9 + 7)) * 9
|
||||
8 + 7 * 4 * 3 * (5 + 9 + 8 * 7 * 3)
|
||||
9 + (4 * (2 * 6 + 7) + 5 * 4 + 8 + (6 + 7 * 8 * 2)) + 9 + 5 + 8
|
||||
3 * ((5 * 2 * 8 * 7 * 2 + 4) * (3 * 3 * 5 + 2) + 7 + 8) * 8 * 2 + 3
|
||||
(8 * 2 + 5 + (4 * 9 * 7)) * 5 + (9 * 8) * (5 * (7 * 8 + 4 * 4) + 3)
|
||||
((7 * 6 + 9 + 7 + 9 + 9) * 2 * 8 + (6 + 4 * 7 * 2 * 2) * 7 + (2 + 9 + 9 + 5 + 4)) * 5 * 2 + 7
|
||||
7 + 2
|
||||
4 * ((2 * 6) * 5 * 5 + 9 * (7 * 7 * 3 + 8)) + 2
|
||||
6 * 8 + 5 + 4 * (5 + 8)
|
||||
4 + 6 * (4 * 5 * 3 * 5 * 5 * 6) * 8 * 5
|
||||
7 + ((6 * 6 + 2) + 7 * 7 + 7 * 9 * 6) + 6
|
||||
(7 + 3 * (2 * 5 + 3 * 9)) + 2 * 2
|
||||
6 + 3
|
||||
2 * 8 * (3 + 8 * (4 + 6 * 4) * 8 * 2)
|
||||
8 * ((4 + 8 * 5 + 7) + 6 + (4 + 8 + 4 + 9 * 7 + 9) + 2) + 5
|
||||
(7 + 7 + 2 + 3 + 6 * 3) * ((7 + 5 + 8 + 5 * 6) + 4 + 6 * (3 + 3) * (4 + 6 * 9 * 6 + 4) * 7) * 3 * 9 + 5 + 4
|
||||
5 * 7 * (5 * (2 + 5 * 7 + 7 * 5) + 9) + 3
|
||||
8 + 2 * 4 * 3 + (8 + 3 + 4 + 3 + 2 * (4 * 5)) * 5
|
||||
3 + (8 * 3) * 7 + 4 * 5 * 2
|
||||
(7 * (7 * 2 * 7 * 3) * 3 + 2 + 7 * 6) * 4 * 6 + 6 + 6
|
||||
(5 + 2 + 2 * 8 + (2 * 9 + 7 + 3) + 5) * 9
|
||||
(6 + (7 + 8 * 2 + 9) + (7 * 3 * 4 * 5) + 6 * 3 * 4) + (3 * 2 * 5)
|
||||
4 + 7 + (8 * 7 + (5 * 4))
|
||||
8 * 2 * 5 * (9 + 4) + (3 * 7)
|
||||
(3 + 4 + 8 + 6 + 2) * 9 + 6 + 6 + 3
|
||||
(9 + (3 * 4 * 5 * 8 + 5) + (5 + 8)) + 5 * ((2 + 5) + (7 + 9) * 2) * (6 * 3) + 8
|
||||
9 * (3 + 9 + 8 * (9 + 7 + 9 + 8 * 6) + 8 * 8) + 2
|
||||
7 * ((9 * 2 + 8 * 4 + 7) * 4 + 3 + (5 * 3 * 5 + 3 + 4)) * 5 * 7
|
||||
5 + 2 + (8 * 8) + 8
|
||||
4 * (4 * 9 + (7 * 6 + 2 * 2 + 5 + 8) * 9 + 7) * 3 * 7
|
||||
9 + 9 + (4 * (8 + 2 * 5 * 9 + 9 * 2) * 4 * 7) + (6 + 2) * ((8 * 7) + 9 * (7 + 7 * 7) + 2 + 5 + 2) + 6
|
||||
9 + 4 + (3 * 9 * 3 * 9) + (3 + (2 + 9 + 9 + 8 + 7) + 5 + 9 * 3) * 7 * (4 + 7 * 8 + 7 * (4 * 2 + 5 * 8 + 9 + 8) + 3)
|
||||
6 + (2 + 6) * (6 * 2 * 2 + 7) * 4 * 6
|
||||
6 * (2 + (6 * 7 + 7 * 9) * 6) * 3 * 8 + 3
|
||||
8 + (5 + 4 + 6)
|
||||
9 + 2 * (5 * 5 * 5) * 2 * 5
|
||||
4 * 4 * ((3 * 3) * (9 + 7 + 5) + 5 + 9) + 7 * (4 * 2 * 4) * 7
|
||||
((4 * 5 * 7 * 7 + 3) * 9) * (6 * (7 * 8 * 7 + 3 + 7) + (4 * 2 + 3 + 3) * 4 + 6)
|
||||
4 * 2 + 3 + 2 * (2 + 2 * 2 * 8)
|
||||
4 + ((3 + 8) * 7 + 2 + (9 + 4 + 9 + 3 + 4 + 6) * (7 * 5 + 8)) + 4 + 5 * 8 + 2
|
||||
(5 * 2) + 3 + (3 + 9) + 4 + 4 * 5
|
||||
6 + (5 + 8 + 6 + (7 + 5 + 9)) + (3 * 5 + 8 * 3 * 4) * 4 + 4 + 5
|
||||
((7 + 4 * 6) * 7 * 2 + 6) * 7 + 8
|
||||
7 * 5
|
||||
2 + 9 * 4 + 9 + 4 + (8 * 9)
|
||||
5 + 5 * ((5 + 6) + 2 * 4) * (8 + 8 * 5) + 3
|
||||
5 * 5
|
||||
4 * 3 * 4 + 3 * (7 * 9) + 4
|
||||
4 + 4 * (8 * 3 + 2 * 8 + 2) + 4 + 3
|
||||
(8 + 5 + 4 * 4 + 6 * 9) + 8 * 6 * 3
|
||||
8 + 6 + 3 + ((2 * 9 + 2) + (7 + 7 + 3)) + 6
|
||||
(4 + 5 + 8) * 8 + (7 * 9 + 3 * 3 + 9 + (8 + 5 + 7 + 3 + 9)) + (3 * 3) * 8
|
||||
(4 + 4 + 4 * 6 + 4 + 9) * 6 * ((8 + 6 + 3 + 2 * 8 + 2) * 4 + 6 * 8 * 7) * 5
|
||||
6 * 6 + 3 * (2 + 7 + 3) * 4 + 5
|
||||
((2 * 4 + 3 * 3 * 9 * 3) * 7) + 2 + 8 + 6 * 2
|
||||
5 * (5 * 4) + 6
|
||||
((7 + 6) + 7) + 3 * 2 * 9 * 6 + 4
|
||||
6 + 8 + ((4 * 9 + 5) * 4) * (5 + 7 + 8 * 8 * 2) + 9
|
||||
8 * 4 * 8 * 9 * 2
|
||||
5 + 2 + (8 + 9 * 6 * 7 * 6) * 8
|
||||
6 * (9 * 5) + (5 + 2 + 6 * 8) * 6 * 6 * (4 + 7 + 8 * 8)
|
||||
2 * 3 * 6 * 8
|
||||
3 + (4 + 5 * 8 * 8) * 2 * (9 * (5 * 3 + 8 + 6) * 2 + (5 * 7 * 3) * (4 + 5) + 7)
|
||||
6 * (5 * 4) * 5 + 4 + (6 + 2) + 6
|
||||
2 * (4 * (7 + 2 + 3 + 3 * 8) * (9 + 3 * 3) + (6 * 8 * 5 * 7) + (6 + 5) + 7) * (3 + 8 + (5 + 4 + 8 + 6) * 3 + 2 + 3) * 8 + (3 * 3) * 9
|
||||
(5 + (4 * 8 * 7) + 7 * (7 * 9 + 2 + 5 + 6)) + 4
|
||||
6 + ((3 + 9) * 4)
|
||||
9 + ((4 + 4 + 5 * 6) * 8) * 2
|
||||
(4 + 2) * 3 * 3 + 3
|
||||
5 + 2 + (8 + 7 + 5)
|
||||
6 + (7 + 4 * 9 * (6 + 8 * 8 + 3) * 8)
|
||||
3 + 3 * 6 * 3 + (4 * (2 + 6 * 7) * 8)
|
||||
7 * 5 + 8 * 7 + (9 + 4 * (7 + 6 + 2 * 7 * 9) + 9 + 9 * 4) + (3 + 6 + 5 * 6 * 4 + 9)
|
||||
5 + (9 * (5 * 7 * 6 * 8) + (8 * 3) * 6 + (2 + 7 * 8)) * (9 + (5 + 7 * 2 * 6 + 9 + 7) + 4 + 8 * 3) * 7
|
||||
(6 + 7 * 7 * 9 * 4) * 3 + (5 + 7) * 7 * 5 * 6
|
||||
(9 + 6 * 5 + 3) * (2 + 6 + 6) + 4 * 6 + 3
|
||||
5 + 8 + ((9 + 8) * (3 * 3 + 8 * 8) * 2 + 3) * 6 * 4
|
||||
((3 + 9 * 2 * 8 * 7) * 7 * 8 + 3 + 7) * (8 * 9) * 5
|
||||
5 + 3 + (4 * 4 * (8 * 8 + 4 * 4) + 4 + 5 * 6) * 4 + 2 + 7
|
||||
5 + ((6 + 4 + 9 + 3) * 6 + (2 + 4 * 9 + 4 + 7 + 7)) + 4 + 9 * 8
|
||||
2 + 4 * 7 * 5 * ((5 + 4 + 6) + 4 * 4)
|
||||
8 * 6 + (4 + 8 * 5 * 6 + 4 * 9) * 9 + (2 + 8)
|
||||
((8 + 3 * 2 * 6) * (7 + 8 * 8) * 9 + (2 + 5) + 4) * (2 * 9 * 5 + (9 * 4 * 2 + 7 + 8) * 2 + 2) * 6
|
||||
4 * ((5 * 5 + 6 * 8 * 5 * 9) + 4 * (3 + 7 * 6 + 4) * 4) + 2 * ((9 + 8 + 9) + 9 * 2) * 8 + 4
|
||||
2 * 8 * 6
|
||||
(7 + (7 + 8 * 9) * 7 + (5 * 8 * 6 * 9 + 6 * 4)) + ((5 + 9 * 6 + 7) + 8 + 7 + (8 * 7 * 4 + 5 + 2) * 5 + (9 + 3 + 9 * 2 * 6 * 3)) * (4 + 5 * 4) + (8 * (5 * 5) * 9 * (3 * 3) + 5) * 4
|
||||
(6 + 5 + 5 * 5) * 4 + ((8 + 6 + 8) + 5 + 5 + 7 * 9)
|
||||
9 * (9 * 2 + 4 * 2 * 4)
|
||||
4 + (6 + 2) * (4 + 2 + 2 * 5) + 2
|
||||
5 * (6 + 8 + 5 * 2 * (7 * 2 + 2))
|
||||
((7 + 5) * 2 * (3 * 5 * 9)) + 7 * (7 * 5 + 9 * 9 * (5 * 9))
|
||||
7 + 5 * (2 * 3 * 4 + 9 * 7 * 9) + (2 + 8 + (3 * 6) * 7 * 7 * (5 * 8 * 7 + 8 * 6 * 9)) * 5
|
||||
9 * 3 * ((9 + 7) * 7 * (2 * 9 + 5 * 9 * 7 + 8) + 6 * 6 + 6) * (9 + 7 + 6 + 9 * 7)
|
||||
8 + 9 * 4 * ((7 * 3 + 6 + 6 * 7 + 9) + 8 * 5 * 2)
|
||||
3 * (3 * (5 + 5 + 5 * 2))
|
||||
4 * 4 * 8 * 6 + (3 + (5 + 5 + 5 + 6 * 6) * 8 * 9 + 9) + 3
|
||||
(3 + 8) + 4
|
||||
6 + 5 + 3 + ((2 + 5 + 6) + (9 + 5 * 4 * 9) + 6 * 7 + 5)
|
||||
(6 * 8 * (2 + 2 + 8 + 8 + 2) + 7 + 6 * 3) + ((7 * 3 * 9) + 2 * 4 * 4 + 2) + 5
|
||||
6 * ((6 * 8 + 3 * 9) + 2 * 9) + 3 * (6 + (3 * 7 * 4) + 4 * (6 * 8 * 3 * 7 + 3 * 8) * 6 * 7) * 6
|
||||
5 * 8 * (7 * 7 + 4 * 7) + (2 * 4 + (3 * 2 * 4 * 9) + 4 + 2)
|
||||
(3 * 8) + 3 + 6 + (3 * 3 + 9 * 6 * 8) + 3 + 5
|
||||
((6 + 5 + 7 + 3) * 7 + 9 * 5) + 9 + 2
|
||||
3 + 2 * ((9 + 9) * 8 + 5 * (6 + 4 * 6) + 4 + 7) + 9 + 4 * 4
|
||||
5 * 6 + (5 + 6 * 8 * 5 * (8 * 2 + 7) * (7 * 6 * 2 * 2 * 7 * 6))
|
||||
8 + 4 + 3 + (4 * 7) * 2 * (2 + (3 + 8 + 8 * 2 * 9))
|
||||
7 + 5 + 3 + ((9 * 9 + 2 * 8 * 6 + 5) * 2) + (3 * 7 + 6 * 4 * (8 * 6 + 8 + 8 + 7 * 3) + (9 + 3 * 8 * 6 + 4)) * (9 * 6 * 9 * 6)
|
||||
5 + (2 + (6 * 3 * 3 + 9 * 8 * 8) + 3) + 9 * 6 + 6
|
||||
6 + (2 + (3 * 5 + 2 + 4)) + 7 * 9 * (8 * 9 * 6)
|
||||
((4 * 4) + 2 + 7 + (5 + 3 * 2 + 9 + 8 + 4) * 5) * (2 * (6 + 8 * 9 + 7) * 9 + (7 + 5 * 7) * 8) + 6 * 3 * 3
|
||||
(7 * 5) * (5 + 3 + 5)
|
||||
(2 * 6 * 9 + 9 + 6) + 9 * 8
|
||||
6 + (9 + 6 + 7 * 7 * 3 + (9 + 8 + 2 * 3 + 4 + 7)) + 9 * ((2 * 5 + 4 * 6 * 6 * 7) + (6 + 5 * 4 * 5 * 8) + 9) + ((5 + 7) * 5 * 4)
|
||||
(7 * 2 + 7 * 8 * (7 + 6)) * 2 * 2 * 2
|
||||
(6 + 5 * 2 + 3 + 5) * 8 + 4 + 2
|
||||
3 + 4 + 3 + 7 * ((2 * 8 * 8 * 3 + 4 + 4) * 8 * 2 * 9 + 4 + 9)
|
||||
7 + (5 * (7 * 9 + 7 + 2 * 7) + 9 + 3 + 5 + (8 * 9))
|
||||
8 * (2 * (8 + 4 * 3) + 7 * 7 + 5 + 8) + 3 + 6 * 8
|
||||
(8 + 3 * 5) * 6 + 2
|
||||
3 + 8 * ((3 * 8) + 8 + 5)
|
||||
5 * 9 * 5 + ((5 + 6 + 7) + 4) + ((5 + 8 + 3 + 4 + 3) * 8 * 3)
|
||||
7 * (6 + 4 + (7 + 4 + 4 + 6) * 3 * 3 + 2) + 7 + 8 + 4 + 3
|
||||
2 + ((3 + 8) + 2 + 9 + 4 * 3)
|
||||
4 + 9 * 3 + 9
|
||||
(7 + (7 * 4 + 7) * (6 * 6 * 9 * 4) * (2 + 5 + 8 + 3)) * 3
|
||||
(8 + 2 + 4 * 7 * 3) + 2 * ((6 + 2 + 2) + 7 * 8 * 8 * 5 * 8) + 7 + (5 + 8 + 2 * (9 * 9) + 3)
|
||||
8 * 2 + 6 * ((5 * 3) * 6 * 2 * (7 * 2 + 4 * 4 + 9)) + 4
|
||||
4 * 3 * (8 + 7 * (2 + 4 + 7 + 4 + 3)) * 9
|
||||
7 + (6 + (6 + 2) + 8 + 9 + 3) * (3 + 9 * (3 + 5 + 6 + 7 + 6) + (8 * 8 * 7) + 5 + 8) * 9 * 2 * 8
|
||||
3 + 6 * (3 * 5) * (9 + 4 * 3) + (5 * 6 + 3) * 6
|
||||
6 + (5 * 6 * 7 * (2 * 4) * 9) * 7 * 7 * 6 * ((2 * 6 * 2 + 3) + 7 + 9 * 2 + 6 * 6)
|
||||
(4 * 4 * 2) * (4 + 3)
|
||||
7 * 8 * 9 * 6 * 2 + (8 * (8 + 6 + 6) + 3 + 5 + 2)
|
||||
(9 + 2 + (8 * 9 * 5 + 7) + 3) * 9 * (7 + 8 + 3 * 4 + 5) + 8 * (5 * 5 + (4 + 5 + 5 * 3 + 8) * 4) + (7 + 3 + 7 + 4)
|
||||
8 * (2 * 2 + (8 + 7 * 9 * 2) * (8 * 2 + 5 + 4) * 9 + 8) * 6 + 3 + (4 * 3) * 7
|
||||
(5 + 7 + 9 * 6 + 4) * 9
|
||||
(3 + (5 + 3 + 4) * 3) + 3 + 8 * ((5 * 8 * 6) + (8 + 6 * 4 * 4 + 8) * 8 + 2 * 4 + 7) + (2 * (5 * 5 * 3) * 2 * 9)
|
||||
(8 + 2 * 8) + 9 * 8 + 7
|
||||
4 * (2 * 3 + 8 + 3 * 5) * ((3 * 3 * 8 + 7) * (7 + 5 + 8) * 6) + (9 * 5) + 8
|
||||
7 * (6 * 3) + (7 + 8 + (2 + 5) * 3) + 7 + 6
|
||||
5 + 9 * 2
|
||||
9 * 2 + 8 * (3 * (6 * 7 * 7) * 8) + 9
|
||||
((2 + 8 + 7 + 6) + 4 * (6 * 5 + 7 * 4 + 5) * 8) * 9 + (7 + 2 * 5 * 5 * 3 * 3) + 3
|
||||
6 + 3 * 3 + (8 + 4)
|
||||
(8 + (8 * 2) + 4) * 5 * 4 + 5
|
||||
(5 * 5 * 5 * 8 + 8 + 7) + (6 + 9) + 4 * 3 + 4
|
||||
(3 + (2 * 9 + 2 + 9 + 4) + 2 + (5 + 3 + 2)) * 5 * 3 + 5
|
||||
6 + 3 * ((8 + 7 * 8 * 7 + 9) + 3 + 3 + 9 * (7 + 5 + 9) * 9) + 5 + (7 * 8 + (5 * 7 + 5 * 9 + 4))
|
||||
(4 * 9) + 7 * 9
|
||||
(3 + 7) + 2 + (5 * 2 * 4 * 6 + 5)
|
||||
5 * 4 * 2 * ((9 * 4 * 7) * 2 * 3) + 3 + 6
|
||||
(5 + 2 * 7 * 7) * (4 * (3 * 8 * 2) * 3 * (2 + 3 * 8)) + 4 * 6 + 8 + 7
|
||||
7 * 4 + 2 + (6 + 2 * 5 * 2 + 6 * 9) + 7 * 2
|
||||
8 + (4 * 4 * 7 * 9 + 5 + 6)
|
||||
(4 + 7 + 8 * 6) + (3 * 5 + 4) + 4
|
||||
6 + 2 + 3 + 2 * 3 + 9
|
||||
6 + ((7 * 6 + 5) + 4 + 9 + (5 + 6 * 6 + 5 * 2 * 9) * (2 * 9)) + 9 + 5 * 2
|
||||
8 + 3 * 4 * 3 * (3 * 9 * 2)
|
||||
9 * (7 * 7 * 4) + 3 + (9 + (6 + 6 + 2 + 3 + 5 + 6) * (3 * 7 * 9 * 3) * 6 + 8 * 3)
|
||||
5 * (9 * 2 + (6 + 2 * 5) + 5)
|
||||
4 + 3 + 9 + 7 + 5 + (3 * (2 + 8 * 6) * 4 + 2)
|
||||
3 * ((2 + 5 + 2 + 6) + 3 + 4 + (7 + 9) * (7 + 8 * 4 + 9) * 3) + 9 + (8 + 6)
|
||||
8 + 4 * 4 + 7 + ((3 * 9 * 2 + 2 * 8) + (3 + 6 + 2 * 5 * 4 * 8) * 8 * 8)
|
||||
4 + 4 * ((5 + 3 + 2 * 4 + 7 * 8) * (5 * 6 + 9) + 5 * 3)
|
||||
7 * 8
|
||||
3 + (5 * 3 + (5 * 9) * 2 + 4) + 2 + 3
|
||||
6 + 8 + 3 + (2 * (6 + 5 + 3 * 8 + 9) * 3 * 9) * (6 * 8)
|
||||
2 * 9 * 4 * (6 * 2 * 6 * 3 * 8) * 4
|
||||
6 + (3 * 4 * 7 + 5 * 5 + 2) * 4 + (6 * 5 * (6 + 2 + 9 + 6 * 8) * 2 + 5) + 4
|
||||
6 * ((6 + 4) + 9 * 5 * 3 + (9 * 5)) * (4 + 2 * 7 * (4 * 9 * 3 * 8) * 4) + 3
|
||||
7 * 2 + 6 * (3 * 6 + 6 * 5) * 7 * 7
|
||||
3 + 8 * (3 * 2 + (9 * 3 + 8 * 7 + 8 + 4) + 6 + 3 + 5) + (6 + 8 + 7 * 3) * 9 * (4 * 3 * 6 + (9 + 9 * 9 * 2 * 6) + 4 + (6 * 4 + 5 + 9 + 9 + 7))
|
||||
4 * 8 * (8 * 5 + 3 * 6 * 7 + 9) * 9
|
||||
8 + 4 * 9 * 4 * 8
|
||||
(3 * 7 + (5 * 2 + 7 + 5 * 6) + 9 * 5) * 6 + 6 + 2 * 5
|
||||
(8 + (4 * 8 * 8) * 7) + 4 * 8 * ((4 * 4 * 5) + 8 + 8 + 2) + ((6 * 8) * 8 * 8 * 8 * 2) + 8
|
||||
4 * (6 + 2 + 6 + 9 + 7) * 4 + 7 + 9
|
||||
5 + (2 + 6 * 8 + 5) + (6 + (8 + 9 + 5) * 4 * 3) * 4 * 5
|
||||
9 * 6 + 5 * (4 + 2 + (7 + 9 * 6)) + 5 + 6
|
||||
8 + ((8 + 3 + 5 + 3 * 8) + 5 + 3) * 4 * 3
|
||||
2 + (3 + 5 * (8 * 2) + 8 + 5) * 8 + 4 + (8 + (9 + 8) + 8 * 9 * 7) + 9
|
||||
7 * (4 * 2 + 5) * 8
|
||||
3 + 5 + 7 + (6 + 2 * 7 * 7 * 5) + ((3 * 4 + 8 * 5 + 6) + 4 * 5)
|
||||
(9 + 6) * 7 * (9 + 3 + 4 * (8 + 8 * 3 + 6 + 8 * 2))
|
||||
2 + (6 + 5 + (7 * 5 + 5 + 9 + 7 + 6) + 2 + 2 * (8 + 8))
|
||||
4 * 9 + 2 * 9 + 9 + 8
|
||||
((2 * 7 * 5) * 8) * 8 + 4 + 8 * 4
|
||||
7 * 5 + (8 + 9) * 3 * 6
|
||||
8 + ((9 + 7 + 8) + (8 * 5) + 2 + 7 + 3 + 3) + 3
|
||||
6 * (5 * (7 + 6 + 5 * 9 + 8 * 5) * 6) + 7 * 9 * ((2 + 5 * 8 * 2 + 3) * 3 + 7 + 5 * 3) * 2
|
||||
3 * (3 + 5 + 4) * 6 * 9
|
||||
6 + ((8 * 5 + 3 + 9) * (5 + 2 * 4 * 5 + 5) + (2 * 3) + 4 + 7) + 7 + 8 * 6 + 4
|
||||
((9 * 2 + 8 * 9) * 4 + 5 * 3 * (8 * 2 * 7)) + (7 + 4 * 2 + 6) * 9
|
||||
(6 * 5 + 7 * (5 * 5 + 4 + 7 * 7 + 6) + 2) * ((4 + 6 * 5 * 6 + 7) + 9 + 5) * 7 * (4 + 7 * 6 + 5) * 5
|
||||
8 * (3 * 6 + 5) + 9 * (9 + 6 * (4 * 6) + (7 + 8 + 5 + 3)) * (3 * 7 * 8 * 2) + 9
|
||||
8 * 3 + (5 + 3) + 8 * 4 + (4 + (7 + 9 * 5 * 3) * 6 + (7 + 5 + 4) + 8 * 8)
|
||||
2 * 3 + ((8 * 8 * 8 + 4) * 7 * 7) * 5 * 8
|
||||
(6 * (7 + 3 + 8 * 5 + 2) + 2 * 4 + 5 * 5) * 2 * (8 + 3 + 3 + (6 + 4) * (9 * 3)) + 6 * 9
|
||||
8 * (7 * 6 * 8 * (3 * 6 + 4 + 6 + 2 + 2) * 6) + 8 * 8 * 6
|
||||
(7 * 5 * 5) * 7 * ((3 + 6 + 3 + 4 + 2 * 2) * 8 * (7 + 9 * 9 * 9))
|
||||
((5 + 7 * 9 * 2 + 7) + 7 + 5 * 6 + 3) * 6 * 2 * 3
|
||||
5 + (5 * (9 + 9) + (7 * 7 * 4 + 2) * 3)
|
||||
((8 * 8 + 2 + 8 * 9) * 5) + (2 + (9 * 6 + 9 + 7) * 7)
|
||||
3 + ((7 * 4 * 4 * 5) * (8 + 3 * 4 + 4 * 9) * 5 * 3 + 7) + 4 * 2 * 7 * (3 * 6 * 6)
|
||||
((9 * 7 + 6 + 7 * 9 + 2) * 4 + 3 + 4 + 4 * 6) * 8 + (4 + (8 + 2 * 6 * 4 * 3)) + (5 + 2 * 6 * (4 * 5 + 4 + 2)) + 4 * (6 + 3 * (2 * 2 * 6 * 3) + 8 + 4 * 5)
|
||||
(5 * (7 + 9 + 5) + 6) * 5 * (6 + 7 * 9 + 6) * 9 * 5 + 9
|
||||
(4 * 4 * 6 * (5 * 8 + 3 + 8) + 5) + (9 * (3 * 9 + 3 * 9) + 5 + 8 + 2 * 3) * 3 * 2 + 8 * 5
|
||||
7 + 5 * (3 + 8 + 6 * 9 + 5 * 8) * ((9 * 9 * 4 * 9 + 3) * (6 + 9 * 5) * 8 + 4 + 6)
|
||||
7 + 8 * ((3 + 7 * 5) + 3 * 2 + 2 * 3 + 7) * 9 + 8 * 7
|
||||
3 + 4 + (5 * (9 + 9 + 3 * 6 * 4 * 3) * 4) * (4 * (7 * 6 * 3 + 5 * 2 * 9) + (7 * 3 + 5))
|
||||
3 * (2 + 8 + 2) * 6 * (4 * 4)
|
||||
2 + 2 + 3 * 5 + (3 + (6 + 2) + 9 + 7) * (3 * 3 + 5 + 8 + 7)
|
||||
4 + 5 + 6 * 6 * 6 + (3 * 2 * 3 * (2 * 6 + 9) + 6 + (5 + 2 + 9 * 6))
|
||||
((4 + 9) + 2) * 7 + 3 * 4
|
||||
2 + 6 * ((2 * 7 * 8 * 3 + 8 + 4) + 9 + 6 + 9 * 2 + 9) + 7 * 6
|
||||
9 * 7 + ((2 + 5 * 2 * 7 * 8) + 6 * 2 + 3 + 4) * 5 * (5 + 2 * 7) * 8
|
||||
4 * (8 + 5 * 6 * 8) + 2 + 3 * 7
|
||||
(2 * 2) * 9 * 6 * 3 + 9
|
||||
9 + 2 * (7 + 5 + 7 + (3 + 7 * 2 * 2 + 3) * 3)
|
||||
(2 + 5 * 9) * (4 * (9 + 2 * 4 + 3 + 2) * 2 + 8 + (6 * 7 + 9 + 5)) * 3 + 8
|
||||
(6 * (6 + 7 * 7) + 7 * 6 * 7) + ((7 * 6 * 4) * 6 * (8 + 8 + 5 * 7 * 8 + 8) + (4 + 5 * 5 + 5 + 3 * 9) + 8)
|
||||
9 * (6 * 9 * (8 * 2 * 6) + 4 * 4)
|
||||
(5 + 5 * 5 + 8) * 6 + 5 * 2
|
||||
4 + ((8 + 7) + 5) + 6
|
||||
9 + 6 * (7 + 4 + (9 + 4 + 2 + 8)) + (8 * 5)
|
||||
(3 * 8 + (6 + 9 * 8 + 6)) + 3 + 4 * 8 + 5 * 3
|
||||
3 + 6 * (7 * 8 * 6 * (5 + 8 + 6) + 5 * 4) * ((8 + 9 + 6 * 8) * 9 + 6 * 6 + 2 * 2) * 4
|
||||
7 * (6 * (5 * 5 + 9 * 7 + 5 + 9) + 8 + 9 + 2 * (6 * 7 * 7)) * 3
|
||||
4 + 2 * (5 * (3 * 8 * 3) * (5 + 9 + 8 * 9) + 9 + 7) * 7 + 5
|
||||
6 * 5 * (5 * 3 * 9 * 4 * 2) * 9 + 7 * 4
|
||||
3 * (4 * (7 + 2) + 4 + 6 + (3 + 6 + 6 * 5)) + 5
|
||||
7 * 7 * (5 + 9 + 9) * (8 * 6 * 5 + 4 * 2)
|
||||
6 + (9 * 4) * ((4 * 2 * 4 * 4 * 6 * 7) + 9 + (2 * 9 + 9 + 9)) + 2 + 4 + 4
|
||||
9 * (6 * 5 + 9 * 2 * 4) + 7 + 8 * 8 + 9
|
||||
(6 + 7 + 8 * 2 * 4) * 5 + 2 + 2 * 5 + 6
|
||||
8 * 7 * (9 * 2 * 4 + 3 + 4 * 4) + (8 * 8 + 9 + 6) + ((7 * 7 + 2 * 9) * (2 * 8 + 2) * 6 * 6) + 8
|
||||
1146
2020/input/2020/day4.txt
Normal file
1146
2020/input/2020/day4.txt
Normal file
File diff suppressed because it is too large
Load Diff
900
2020/input/2020/day5.txt
Normal file
900
2020/input/2020/day5.txt
Normal file
@@ -0,0 +1,900 @@
|
||||
BFFFFBBRRL
|
||||
FBBBBBBRRL
|
||||
BBBFFBBRRR
|
||||
BFFFFFFLRL
|
||||
FBFFBFBRRR
|
||||
BFFBFFBLRR
|
||||
FFBBBFBRRR
|
||||
BBFBBBBLRL
|
||||
FBFFBFFLRL
|
||||
BFFFBBFLLL
|
||||
FBFFFFFRLL
|
||||
FBFFBFFRRL
|
||||
BBBFBFBRRL
|
||||
BFFBFFFLLL
|
||||
FBFFFFFLLL
|
||||
BFFFBBFLLR
|
||||
FBBFFBFRRR
|
||||
FFBBFBFLRR
|
||||
FFFBBBFLRL
|
||||
FFBFBBBRRL
|
||||
FBFBBBBLLR
|
||||
BBBFFFBLLR
|
||||
FBBBFFFLLL
|
||||
FFBFBFFRLR
|
||||
FBFBBBFLLR
|
||||
BBBFBBBRRR
|
||||
FBBFFFBLRR
|
||||
FBBFFFBLLR
|
||||
BFBFFBBLLL
|
||||
BBFFFFFRLR
|
||||
BBFBBFFRRL
|
||||
BBBBFBFRRR
|
||||
BFFFFBFRRR
|
||||
FBFFFFBLLR
|
||||
FFBFBFBRLL
|
||||
FBFFFFBLRL
|
||||
BFFFFFFLLL
|
||||
BFBBFBBLRR
|
||||
FFFBBBBRRL
|
||||
BBFFFFBLRL
|
||||
FFFBBFBRLL
|
||||
BBBBFFBRRR
|
||||
FBBBBBFRLL
|
||||
BFFBFBFRLL
|
||||
FBFFBFFLLL
|
||||
FBBBBBBRLL
|
||||
FFFBBBFRRL
|
||||
BBFFFFBRRR
|
||||
FFBFBFFLLR
|
||||
FBBFFFFRRR
|
||||
BFFFFFBRRL
|
||||
BBFFFBBRLR
|
||||
BBBBFFFRLL
|
||||
BFFFFBFRLR
|
||||
BFBBBBFLRL
|
||||
FFBFBFFRRR
|
||||
BFBBFFBLRR
|
||||
FFBBBBBRRR
|
||||
FBBFBFFLRL
|
||||
FFBBFBBLLR
|
||||
BBFFBFBRRL
|
||||
BFBFFBFLLL
|
||||
BFFBBFBRRR
|
||||
FBFBBBFLRR
|
||||
FBBBBBBRLR
|
||||
BFBBBFBRRL
|
||||
FBFBFBBRLR
|
||||
FBBBBFFLRR
|
||||
BBFBBFBLLL
|
||||
BFBBBBFLRR
|
||||
FFBBBBBRLL
|
||||
FFBFFBFRRR
|
||||
BBFFBFBRRR
|
||||
FBFBFFBRRL
|
||||
FFBFFFFRLL
|
||||
BFBFBFFLRL
|
||||
FBFBFFBRLR
|
||||
BFFFBFFLLL
|
||||
BFBBFBFLRR
|
||||
BFBBBBFRLR
|
||||
FBFFFBFRRR
|
||||
BFBFFBFLRR
|
||||
BFFFFBBRLR
|
||||
BBFFFBBRLL
|
||||
FBBBFFFRRR
|
||||
BFBFFFFLLR
|
||||
FFFBBBBLLL
|
||||
FBBFBFBLLR
|
||||
FFBBFBFRLL
|
||||
FBBBFBFLLL
|
||||
BFFBFBBRRL
|
||||
BFFFFFFRLR
|
||||
BFFBBBFLRR
|
||||
BFBFBBBLRL
|
||||
BFBBFFFRLL
|
||||
BBFFBFFLLL
|
||||
BBFFBBBLRL
|
||||
FBBBFFFRLL
|
||||
FBFFFFBRRR
|
||||
FFBBBBBLRL
|
||||
FBBFFFBLLL
|
||||
FBFFFFBLRR
|
||||
BBFFBBFRRL
|
||||
BFBFBFFRLL
|
||||
FFBBFBBRLR
|
||||
FFBBFFBLLR
|
||||
FBBFBFFRLR
|
||||
BBFFBFBLRL
|
||||
BBFBFFFRLL
|
||||
FBBFBBBLRR
|
||||
FFBFFFBRRL
|
||||
BBFFBBFLRR
|
||||
BFFBFFBRRL
|
||||
BFBFBFBRLR
|
||||
BBBFFFBRLR
|
||||
BBBFFFFLLR
|
||||
FBFBBBFRLL
|
||||
FBBFBFBRLL
|
||||
FFBBFBFLLL
|
||||
BFBBBFBLLR
|
||||
BFBBBFBRLL
|
||||
BBFBBFBLRR
|
||||
BFBBBFFLRL
|
||||
BFBBBBFLLR
|
||||
BBBFFBFLRL
|
||||
BFBFBBBLLR
|
||||
BFFFBBFRRL
|
||||
FBBBFBBLLL
|
||||
BBFFFFBLLR
|
||||
FBBBBBFLRR
|
||||
BBFFBBFRLR
|
||||
BFBFFBBRLL
|
||||
BFFBBFFLRL
|
||||
BFFBBFBRRL
|
||||
BBBFFBFRRR
|
||||
BBBFBBBLRL
|
||||
BBFFBFBLLR
|
||||
FFBFBFBLRR
|
||||
FBBBFBBLRL
|
||||
BFBBBFFRRL
|
||||
FBFFBFBLLR
|
||||
BFBFBBBRLL
|
||||
FFFBBBFRLR
|
||||
BBFBBBBLLR
|
||||
FBBFBBBLLL
|
||||
FFBBFBFLRL
|
||||
BFFFBFFLLR
|
||||
BFBFFFBRRL
|
||||
BFFBFFFLRR
|
||||
BFFFFFBLLR
|
||||
FBBBBFFLLR
|
||||
FFBFFBFRRL
|
||||
BBBBFBFLLL
|
||||
BBBFFFBLRL
|
||||
FBFFFBBLLR
|
||||
FFFBBFBRRL
|
||||
BBFBFFBRRL
|
||||
FFBBFBBRRR
|
||||
BBBFFBBLRL
|
||||
BBFFFBFRRR
|
||||
FBBBBBFRRR
|
||||
FFFBFBBRLR
|
||||
FBBBFBFRLR
|
||||
FBFBFBBRLL
|
||||
BFBBBBFRRR
|
||||
FFBBBBBLRR
|
||||
BFBFBBBRRL
|
||||
FBBFFBFLRL
|
||||
FBFFBFBRLR
|
||||
FBBBFBBRRR
|
||||
FBFBFBBRRL
|
||||
FBBBBBFRRL
|
||||
FFBBFBFLLR
|
||||
FBFFBBFRRR
|
||||
BFBBBBBRRL
|
||||
FFBFBFFLRR
|
||||
BFFFFBBLRL
|
||||
FFBBFFBRRR
|
||||
BFFBBFFRLR
|
||||
BFFFBBBRLR
|
||||
BBFBFFFRRL
|
||||
BBFBFBFRLR
|
||||
BBFBBBFRRR
|
||||
BFBFBFFLRR
|
||||
FFBFBFBLLL
|
||||
BFFFFFFRLL
|
||||
FFBBFFFLLR
|
||||
FBBBFFBRLL
|
||||
BFBFFBFLLR
|
||||
BFBBFBFLLL
|
||||
FBFFFBFLLL
|
||||
FBBFFBBLRL
|
||||
BBFFFFBRRL
|
||||
BBBFFBFRRL
|
||||
FBFBFFBRRR
|
||||
FBFBBFBRRR
|
||||
BBFFBFBLLL
|
||||
FFBBBFBRRL
|
||||
BFFFBBBLLR
|
||||
FBBBBBFLLL
|
||||
BFFBFFFLRL
|
||||
FBBFBBBRRR
|
||||
BFFFFBFLLR
|
||||
FBBBBBFLLR
|
||||
FBBBFBFLLR
|
||||
FFBBBFBRLR
|
||||
BFBBBBBRLL
|
||||
FFBFBBBRRR
|
||||
BBBFBFFLRR
|
||||
FFBFBFFRRL
|
||||
BBFFBBBRLR
|
||||
FBBBFBFLRR
|
||||
FFBFFFFLLR
|
||||
FBFFFBFLRR
|
||||
BBBFBBFRRL
|
||||
BBBFBFBLRR
|
||||
BBFFFBBLLR
|
||||
BBFFFFBRLR
|
||||
FBBFFBBRLR
|
||||
FFBFFFBLLR
|
||||
BBFBFBFRRR
|
||||
BBBFFFFRLL
|
||||
BFBBFFFRRL
|
||||
BFBBFBBLRL
|
||||
BFFBBBFRLL
|
||||
BBBFFBBRLL
|
||||
FFBBFFFLRR
|
||||
BFFFFFBRRR
|
||||
FBFBBBFLRL
|
||||
BBFFBBBRLL
|
||||
BBFBFBBLLL
|
||||
BFFBBBFLLR
|
||||
BFFFBFBLRR
|
||||
BBBBFBFRLL
|
||||
BFBBBFBLLL
|
||||
FBFBFBBLRR
|
||||
BBFFBFFRLL
|
||||
BFFFBBBLLL
|
||||
BBBBFFFRRL
|
||||
BFFBBBBLRR
|
||||
BBFBBFBRRR
|
||||
BBFBFFBLLR
|
||||
BFFBBBFRRL
|
||||
FBBFBFBRRR
|
||||
BFFBFBFRRR
|
||||
BBFFFBBRRL
|
||||
FBFBFFFLLL
|
||||
FBFBBFBLRR
|
||||
FFBBFBBRLL
|
||||
BBFFFFBLLL
|
||||
BFFFFBFRLL
|
||||
FBFFBBFLLR
|
||||
BBBFFFBLLL
|
||||
BBBFFBBLLR
|
||||
FFBBBBFLRL
|
||||
FBBFBFFRLL
|
||||
BBFBFFBLRR
|
||||
BBFFBFFRRR
|
||||
FBFFBBBLLR
|
||||
BFFBFBFLLL
|
||||
BBFBBBFRLR
|
||||
FFBBBBFLRR
|
||||
FBFBBFBLRL
|
||||
FFBBBFBLRR
|
||||
FFFBFBBRRL
|
||||
BBFFFBBLRR
|
||||
BBFFBBBLLR
|
||||
FBFBFFFRRL
|
||||
FBBBBBBLRR
|
||||
FFBBBBBRLR
|
||||
FFBBFFBLLL
|
||||
BFBBBBBRLR
|
||||
BBFFFBBLLL
|
||||
FBBBBFBRRR
|
||||
BBFBFFFLLL
|
||||
BBFBBFFRLL
|
||||
BFFFFFBLRR
|
||||
FBFBBFBLLR
|
||||
FBFBBBFRRR
|
||||
FFBFFBFLLL
|
||||
BFFBFFBRLR
|
||||
BFFBBBFRLR
|
||||
FBFBBBBLLL
|
||||
BBBFFFBRLL
|
||||
FBBFFFFRLL
|
||||
BFBFFBBLRR
|
||||
FFFBBBFLLR
|
||||
FFBBBFFLLL
|
||||
BFBBFFBRRR
|
||||
BBBFFBFLLL
|
||||
FFFBBBFLLL
|
||||
FBBFFFBRRL
|
||||
FFFBBFBRLR
|
||||
FBBBFBFRRL
|
||||
FFBBBFBRLL
|
||||
FBFFFFFRRR
|
||||
BBFBFBBLLR
|
||||
FBFFBBBRLL
|
||||
BBFBBBBRRL
|
||||
BFBFFBFRRL
|
||||
FFFBBBBLRR
|
||||
BFFFBFFLRL
|
||||
FBFBFBBLLL
|
||||
FFBFBFBLLR
|
||||
FFBBBBFRRL
|
||||
BBFFBFFRRL
|
||||
FBFFBBFLRL
|
||||
BFFBBFBLLR
|
||||
BBBBFBBLLR
|
||||
FBFBBBBRLL
|
||||
FFFBBBBLRL
|
||||
FBFFFFBLLL
|
||||
BFFFFBFLRR
|
||||
BBFBFFBLLL
|
||||
FFBFBFBRLR
|
||||
FBBBFFFLRR
|
||||
FBFBFFFLRL
|
||||
BBFBFBFLRL
|
||||
FBBFFBFRLR
|
||||
FBFFBBBLLL
|
||||
BBFFFFFLLL
|
||||
FBBBFFBRRR
|
||||
FFBBBBFLLL
|
||||
FBBFBFFLLR
|
||||
BFBBFFFLLL
|
||||
BFFBBBBRRL
|
||||
BBFBBBFRRL
|
||||
BBBFFBBRLR
|
||||
BFBBFBBLLL
|
||||
FBFBBFFRRL
|
||||
FBBFFBBRLL
|
||||
FBBFFBBLLL
|
||||
BFBBFBFRRR
|
||||
FBFFFFBRRL
|
||||
FFBBBBBLLR
|
||||
FBFFFFFRRL
|
||||
BBBFBBFLRL
|
||||
FBFBFBBLRL
|
||||
BFFBFBBRLR
|
||||
BFFBBFBRLL
|
||||
BBBFBFFRRL
|
||||
FBFFBFFRLR
|
||||
BFFFBFBRLR
|
||||
BBFFFBFRLL
|
||||
BFBFFBBRLR
|
||||
BFFFBFBLLL
|
||||
FBFFBFFLLR
|
||||
BFFFFBFLRL
|
||||
FFBFBBFLRL
|
||||
FBFFFFFLLR
|
||||
BFFBBBFRRR
|
||||
BBFFFFFRRL
|
||||
FBFFFBBLRL
|
||||
FFFBBBFRRR
|
||||
FBFFBBFRLL
|
||||
BBBBFFBRRL
|
||||
FBBBBFBLLL
|
||||
BBBBFBBLRL
|
||||
BFFFBFBRRR
|
||||
BFBBBBFRRL
|
||||
FBBBBFBRLL
|
||||
FFFBBFBRRR
|
||||
BFBBBBBLRR
|
||||
BFBFBFFRRL
|
||||
BFBBFFBRLL
|
||||
BBFFFBBRRR
|
||||
FFBBBFFLRL
|
||||
BFBBFFFRRR
|
||||
FBFBFBFLLR
|
||||
BFBFFFBLRR
|
||||
BBBFFBFRLR
|
||||
BFBBFFFRLR
|
||||
FFBFBFBRRR
|
||||
BBBBFBFRRL
|
||||
BBFFBFBRLR
|
||||
FBBFFFFLLR
|
||||
BBFBBBBRLR
|
||||
FFBBBBBRRL
|
||||
BFFBFFBLLL
|
||||
BBBFBBBRLL
|
||||
FBBBBFFRLL
|
||||
BFFBFBBLLR
|
||||
BFFFBFBRLL
|
||||
BFFFFBBLLR
|
||||
BBBFBFFLLL
|
||||
BBFFFFFRLL
|
||||
BFBFBFBLLR
|
||||
FBFBFBFLRL
|
||||
BFBBFFBLRL
|
||||
BBFBFBBRRL
|
||||
FFFBFBBRLL
|
||||
BFFFFBFRRL
|
||||
BBBBFFFRLR
|
||||
FBBBFFBRLR
|
||||
FBFFBFBLRR
|
||||
BFBFBFFRRR
|
||||
FBFFFFBRLR
|
||||
FBFBBBBRLR
|
||||
FBBBFBBLRR
|
||||
BBBBFFFLRR
|
||||
BFBBFBFRLR
|
||||
BFBFBBBLRR
|
||||
BFBBFBBRRR
|
||||
FBBFFBFRLL
|
||||
BBBFBBFLLR
|
||||
FBBFBBFLRR
|
||||
FBBFFBBRRL
|
||||
BBFBFBBRLR
|
||||
FBFBBBBRRR
|
||||
FFBBFFFRLL
|
||||
BFBBBFFLLL
|
||||
BFBFBFBRLL
|
||||
BFFBFFBRRR
|
||||
FBBBFFFLRL
|
||||
FFFBBFFRRL
|
||||
BBBFBFBLRL
|
||||
BBBFBBBRLR
|
||||
BBFFFFFRRR
|
||||
BBFBBBFLRL
|
||||
FFBBFFFLRL
|
||||
BFFBBBBLLL
|
||||
FBBBBBBLRL
|
||||
BBBFBFFRLR
|
||||
FBFFBFBLRL
|
||||
BFBFFFFLRL
|
||||
FFBFFFFLRR
|
||||
BBBFFBBRRL
|
||||
FFBBFBFRRR
|
||||
FBBBFBFRLL
|
||||
FFFBBFFLLR
|
||||
BBFBBBFLRR
|
||||
BBFFBFFRLR
|
||||
BBBFFFBRRL
|
||||
BFFFBBBRRL
|
||||
BBFFBBBRRL
|
||||
BBBFFFFRRR
|
||||
BBBBFBBRLR
|
||||
FFBBBBFRRR
|
||||
BBBBFBFLRR
|
||||
FFBFBBBRLL
|
||||
BBBFBFFRLL
|
||||
FBBBFBFLRL
|
||||
BFFFBBBLRL
|
||||
FBFFFBBRLR
|
||||
BBFBBFBLLR
|
||||
FBBBBFBLRR
|
||||
BFBBFBFLLR
|
||||
FFBFFBBLRL
|
||||
FBFBFBFRRR
|
||||
BBFBBFBLRL
|
||||
BBFBBBFRLL
|
||||
BFBFFFBRLL
|
||||
BBBBFBFLRL
|
||||
FBFBBFBRLR
|
||||
BBFBFFBRLR
|
||||
FBBFBFFLRR
|
||||
BFFBFBBLRR
|
||||
FBBBBFFRLR
|
||||
FFBFFBBRRL
|
||||
BBBBFFFRRR
|
||||
BFFFFBBRRR
|
||||
FBBFBFFLLL
|
||||
FBFBBFFRLL
|
||||
BFFFBFFRLR
|
||||
BBBFFBBLRR
|
||||
BBFFFBFRRL
|
||||
FFFBBFFLRR
|
||||
FBFBFFBLLR
|
||||
FBBFFFBRRR
|
||||
BFBFBBFLRR
|
||||
BBBFFFFLRL
|
||||
BBBFFBFLRR
|
||||
BBFFBBFLRL
|
||||
BBBFBBFLRR
|
||||
BBBFBBFRLR
|
||||
BBBFBFBRLR
|
||||
FFFBBFFRLL
|
||||
FFBBFBBLLL
|
||||
BFBFFBFLRL
|
||||
FBBFBBFLLR
|
||||
BBFBFBBRLL
|
||||
FBBBBFBLRL
|
||||
BFFBBBBLRL
|
||||
FBBFBFBRRL
|
||||
FBFBFBFRRL
|
||||
FFBFFBFLRR
|
||||
FBFBFFFRLL
|
||||
BFFFBFBLLR
|
||||
BBFBFBBLRL
|
||||
FFBFFBBRRR
|
||||
BBFBBBFLLL
|
||||
BFFBBBBRLL
|
||||
BFBBBBFRLL
|
||||
BFBBBFBLRR
|
||||
BBBBFBFLLR
|
||||
BFBFFFBLLL
|
||||
FBBBBFFRRL
|
||||
FFBBBFFRRL
|
||||
FBFFBFFRLL
|
||||
FFBBFBFRRL
|
||||
FFBFBBFLRR
|
||||
BBFBFBBRRR
|
||||
BBBFFBFRLL
|
||||
BBBFBFBRRR
|
||||
FBFFBBFRRL
|
||||
FBBBFFBLLR
|
||||
BBFFBFFLRR
|
||||
BFBFBFBLLL
|
||||
BBBBFFFLRL
|
||||
FFFBFBBLRL
|
||||
FBBBBBBLLL
|
||||
BFBFBFBLRL
|
||||
BFFBFBBLRL
|
||||
FBFBFBFRLR
|
||||
FBFBBFFLRL
|
||||
BBFFFBFLRL
|
||||
FFBBBFBLLL
|
||||
FBBFFBBLRR
|
||||
FFBFFFFRRR
|
||||
BFBFFBBLLR
|
||||
FBFFBBBRRR
|
||||
FFFBBBFLRR
|
||||
BFBFFBFRLR
|
||||
BFBBFFBLLR
|
||||
FBFFFFBRLL
|
||||
BFBBBBFLLL
|
||||
FFBFBBFRLR
|
||||
BFFBBFBLRL
|
||||
BFBBFBBRLR
|
||||
BBBFBFBRLL
|
||||
BBBFFFFRLR
|
||||
FFBFFFFRRL
|
||||
FFFBBFFRRR
|
||||
FBBBFBBLLR
|
||||
FFBFBFFLRL
|
||||
BFBFBBBRLR
|
||||
FFBBFFFRLR
|
||||
BFBBBFBRLR
|
||||
BFBFFFBLLR
|
||||
BFFFBBBRRR
|
||||
FBFFFBFRLR
|
||||
BBFBBBFLLR
|
||||
BFBFBFBLRR
|
||||
BFBBFFFLRL
|
||||
BFFBFFFLLR
|
||||
BBFBFBFLLL
|
||||
FFBFFBBLLL
|
||||
FBBBFBBRRL
|
||||
FBFFFFFRLR
|
||||
FBFBFFFLRR
|
||||
BFBBBBBRRR
|
||||
BFBFBBFRLL
|
||||
FBBFBBBRLR
|
||||
BFFBFFBRLL
|
||||
FFFBBBBRLR
|
||||
FBFBFFFRRR
|
||||
FBBFBBFLRL
|
||||
BFFBFFFRRL
|
||||
FFFBBFFRLR
|
||||
FBBBFBBRLR
|
||||
BBFBFBBLRR
|
||||
BBFBFFFLRL
|
||||
FFBFFFBLRL
|
||||
FFBBFBFRLR
|
||||
BFBBFFFLRR
|
||||
BBFBBBBRRR
|
||||
BBBFBBBLLR
|
||||
BBFBBFFRRR
|
||||
BBFFBFBLRR
|
||||
FBBFBFFRRR
|
||||
BFFBBBBRLR
|
||||
BBFBFBFLLR
|
||||
FFBFBFFLLL
|
||||
BFFBBBFLLL
|
||||
FFBBFFBRRL
|
||||
BFBBBFFRLR
|
||||
FBFBFFBRLL
|
||||
BFFFFFFRRL
|
||||
BBBFBBFRRR
|
||||
BFBBFFBLLL
|
||||
FBBFFFBLRL
|
||||
FBBBFFFRLR
|
||||
FBBBBBFLRL
|
||||
BFBBFFFLLR
|
||||
BBFBFBFRLL
|
||||
BFBFBFFLLL
|
||||
FBBBBBBLLR
|
||||
FFBFFFBLLL
|
||||
BFFBBFFRRL
|
||||
BFBFBBFLLL
|
||||
BFFBFFBLRL
|
||||
BFFFFFBRLR
|
||||
BBFBFFFRLR
|
||||
BFBFFBFRRR
|
||||
FBFBBBFRRL
|
||||
FFFBBFFLRL
|
||||
BFFBBBFLRL
|
||||
FBFFFFFLRL
|
||||
BFFFFBBLLL
|
||||
FFBBBFFLLR
|
||||
FFFBFBBRRR
|
||||
BFBFBFBRRR
|
||||
FBBBFFBLRR
|
||||
BFFBFFFRRR
|
||||
BFBBFBBRLL
|
||||
BBFFFFBLRR
|
||||
FBFBBFBLLL
|
||||
BFBBFFBRLR
|
||||
BFFBFBFLLR
|
||||
BFFBBBBRRR
|
||||
FFBBBBFRLR
|
||||
BFBBBFFRLL
|
||||
BFBFBBFLRL
|
||||
FFFBBFBLRL
|
||||
BFFFBFFLRR
|
||||
BFFFBBBRLL
|
||||
BFFBFFBLLR
|
||||
BFFFFBBLRR
|
||||
FBBFFBBRRR
|
||||
BFBFFFFRRR
|
||||
BBBFFFFLLL
|
||||
FFBBBBFLLR
|
||||
BBBBFFBLRL
|
||||
BBFFFBBLRL
|
||||
BBBFBBBRRL
|
||||
BFFBBFFLLL
|
||||
FFBFBBFLLR
|
||||
FFBFFBBLRR
|
||||
FBBFFFFRRL
|
||||
FBFFBBFLRR
|
||||
FBBFBFBRLR
|
||||
BFBBFBBLLR
|
||||
FFBFBBFRLL
|
||||
BFFBBFFRLL
|
||||
BBBBFFFLLR
|
||||
FFFBBFFLLL
|
||||
BFBFBBFRRL
|
||||
FBFBBFFLLL
|
||||
FFBBBFFLRR
|
||||
FBBFBFBLLL
|
||||
FBFBFBFLRR
|
||||
BBBFBFFLLR
|
||||
FBFFFBFLRL
|
||||
BBBBFFBRLR
|
||||
BFBFBBFRLR
|
||||
BFBBFBFRRL
|
||||
BFBBBFFLLR
|
||||
BBFBFBFLRR
|
||||
BFFBFBBRRR
|
||||
FBBFBBFRLL
|
||||
FFBFFFBLRR
|
||||
FBBBFFFRRL
|
||||
BFFBFFFRLL
|
||||
FBBFFFBRLL
|
||||
FFBFBBBLRR
|
||||
FFBFFFFRLR
|
||||
BBBBFBBRLL
|
||||
BFFBFBFRLR
|
||||
FFBBBFBLLR
|
||||
FBBBFFBLLL
|
||||
BFBFBFBRRL
|
||||
FFBFBBBLRL
|
||||
FFBBBFBLRL
|
||||
FBFBFFBLRR
|
||||
FFBFFFFLLL
|
||||
FBBFBBFLLL
|
||||
FBFFFBBRRR
|
||||
FBBFFFFLRL
|
||||
FFBBBBFRLL
|
||||
FBFFFBBRRL
|
||||
BFFBFBFLRR
|
||||
FBFFBFFLRR
|
||||
BBBFBFBLLL
|
||||
FFBFFBFRLL
|
||||
FBFBBFFRLR
|
||||
BFFBBFFLLR
|
||||
FFBBFFFRRL
|
||||
BBFFBBFRLL
|
||||
BFFFFFBLRL
|
||||
FBBFFBFRRL
|
||||
FBBFBBFRRR
|
||||
FFBFFBBRLR
|
||||
BBFBFFFRRR
|
||||
FFBFFFBRLL
|
||||
FBFFFBBRLL
|
||||
BBFBBFBRLR
|
||||
FBFBBFFLRR
|
||||
FBFBFBFRLL
|
||||
BFBBBBBLLL
|
||||
FBBBBFBRLR
|
||||
BFFBBFBRLR
|
||||
BBFFFBFLLL
|
||||
FBFFFBBLRR
|
||||
FFBBFFBRLR
|
||||
FBBBFBBRLL
|
||||
FBBBFFFLLR
|
||||
BFBBBFBRRR
|
||||
BBBBFFBRLL
|
||||
BBFFFFFLRR
|
||||
BBFBBFFLLL
|
||||
FFBFBBFLLL
|
||||
FFBBFBBLRL
|
||||
BFFFBBFLRL
|
||||
BFFBFBBRLL
|
||||
BFBBFBFRLL
|
||||
FBFBFBFLLL
|
||||
FBFFBFBRLL
|
||||
FFBFBBFRRL
|
||||
FFFBBBBLLR
|
||||
BBBBFBBLRR
|
||||
BBFBBBBLRR
|
||||
BFBBBBBLLR
|
||||
FBFFBFFRRR
|
||||
BBFBFFBRRR
|
||||
BBFFBFBRLL
|
||||
FBFFBBFLLL
|
||||
FBFBBFFRRR
|
||||
FBBFFBFLRR
|
||||
BFFBFBFRRL
|
||||
BFFFBFFRRL
|
||||
BBBFBFBLLR
|
||||
BFFFFFBRLL
|
||||
BFBFFFFLLL
|
||||
FFBBFFBLRL
|
||||
FBBBBFBLLR
|
||||
FBBFFFBRLR
|
||||
BBFBFFBLRL
|
||||
FBFFBBBRRL
|
||||
BFFFBBFRRR
|
||||
BFFFBFFRRR
|
||||
FBBBBFFRRR
|
||||
BFBFBBFLLR
|
||||
BBFFFBFLLR
|
||||
FBBFBBBLRL
|
||||
FBBFBFBLRL
|
||||
BBFFBFFLLR
|
||||
FFBFBBFRRR
|
||||
BBFBBFFRLR
|
||||
BBBBFFFLLL
|
||||
BBFBBFFLRL
|
||||
FFFBBFBLLR
|
||||
BFFFBFBRRL
|
||||
FBBBBFBRRL
|
||||
BBFFBBBLRR
|
||||
BFBBBBBLRL
|
||||
FBFFBBBLRR
|
||||
BBFBBBBLLL
|
||||
FFBFBBBLLR
|
||||
FBFBFBBRRR
|
||||
FBFFFBFLLR
|
||||
FBFFFFFLRR
|
||||
BBFBBFBRLL
|
||||
FBFBBFBRLL
|
||||
BFFBBFFLRR
|
||||
FBBFFBFLLR
|
||||
FBBBFBFRRR
|
||||
BFFFBFBLRL
|
||||
FBBFFBBLLR
|
||||
BBFFBBBRRR
|
||||
FBFFBBBRLR
|
||||
FBFFFBBLLL
|
||||
BFBFFBFRLL
|
||||
BBFFBFFLRL
|
||||
FBFFFBFRRL
|
||||
FBBFFFFLRR
|
||||
BBBBFFBLLL
|
||||
FBBFFFFRLR
|
||||
BFBBBFFRRR
|
||||
FBBBFFBRRL
|
||||
BBFBBFFLLR
|
||||
BFBFBFFLLR
|
||||
BBFFFFFLRL
|
||||
BFBFBBBLLL
|
||||
FFFBBBBRRR
|
||||
BBBFFFBLRR
|
||||
BFFFFFFRRR
|
||||
BFBBBFBLRL
|
||||
FBFFBBFRLR
|
||||
BFBFFFBRRR
|
||||
BBBFFFBRRR
|
||||
FBBFFBFLLL
|
||||
FBBFFFFLLL
|
||||
BBFFBBFLLL
|
||||
FFBFFFBRRR
|
||||
BFBFFBBRRR
|
||||
BBFBFFFLRR
|
||||
FBFBBBFLLL
|
||||
FFBBBFFRLR
|
||||
BBFBBFBRRL
|
||||
BBBFBBBLLL
|
||||
FFBFFFFLRL
|
||||
FBFBBBBLRR
|
||||
FBFBBBBRRL
|
||||
FBFBBBBLRL
|
||||
FBFBFFFRLR
|
||||
FBBFBBBRLL
|
||||
BBFBBBBRLL
|
||||
BFBFBBBRRR
|
||||
FBFBBFFLLR
|
||||
FFBFBFBLRL
|
||||
FFBBFBBRRL
|
||||
BBBFBBFRLL
|
||||
FBBFBFBLRR
|
||||
FFFBFBBLLR
|
||||
BFBBBFFLRR
|
||||
FFBFBBBLLL
|
||||
BBBFFFFLRR
|
||||
FFFBBFBLLL
|
||||
FFBFFBFLRL
|
||||
FBBFBFFRRL
|
||||
FBFBFFBLRL
|
||||
BBBFFBBLLL
|
||||
FFFBBBFRLL
|
||||
FFBFBBBRLR
|
||||
BBBFBFFRRR
|
||||
FBBFBBFRRL
|
||||
BFFFBBFLRR
|
||||
BFFFBBBLRR
|
||||
FFBBFFFLLL
|
||||
BBBFFFFRRL
|
||||
BFFBFBFLRL
|
||||
BBBFBFFLRL
|
||||
BFBFFFFRLR
|
||||
BBFFBBFLLR
|
||||
BFBBFBFLRL
|
||||
BFFFFFFLRR
|
||||
FBFBBFBRRL
|
||||
FFBFFBBRLL
|
||||
BFBFFFFRRL
|
||||
FBFBFBBLLR
|
||||
BBFBFBFRRL
|
||||
FBFBBBFRLR
|
||||
BBBBFFBLLR
|
||||
BBFBFFBRLL
|
||||
FBBBBFFLRL
|
||||
FFBFBFFRLL
|
||||
BFBFFFFRLL
|
||||
BBFFBBBLLL
|
||||
FFBFFBFRLR
|
||||
FFBBFFBLRR
|
||||
BFBBFFBRRL
|
||||
FBBBFFBLRL
|
||||
FBBFBBFRLR
|
||||
BFBFFFFLRR
|
||||
BFBFBBFRRR
|
||||
BBFBBFFLRR
|
||||
FFBFFBBLLR
|
||||
BBBBFFBLRR
|
||||
FFBBFFBRLL
|
||||
BBBBFBBLLL
|
||||
BFFFFFBLLL
|
||||
BBFBFFFLLR
|
||||
BBBBFBFRLR
|
||||
FFFBFBBLRR
|
||||
BFBBFBBRRL
|
||||
FBFBFFFLLR
|
||||
BFFBBFBLRR
|
||||
BFFFFBBRLL
|
||||
BBFFFBFLRR
|
||||
FFBFFBFLLR
|
||||
BFBFFBBRRL
|
||||
FBBBBFFLLL
|
||||
BFBFBFFRLR
|
||||
FBBBBBFRLR
|
||||
FBFFBFBRRL
|
||||
FBFFBFBLLL
|
||||
FBBFBBBRRL
|
||||
BFBFFFBRLR
|
||||
BFBFFFBLRL
|
||||
FBFFBBBLRL
|
||||
BBBFBBBLRR
|
||||
FFBBFBBLRR
|
||||
FBBBBBBRRR
|
||||
BFFFFFFLLR
|
||||
BFFFBBFRLL
|
||||
FBBFBBBLLR
|
||||
FFBBBFFRRR
|
||||
FBFFFBFRLL
|
||||
BBFFFFBRLL
|
||||
BFFBFFFRLR
|
||||
FFFBBBBRLL
|
||||
FFBFBFBRRL
|
||||
FFBBBBBLLL
|
||||
FBFBFFBLLL
|
||||
BBFFFFFLLR
|
||||
BFFBBFFRRR
|
||||
BFFFBBFRLR
|
||||
BFFBFBBLLL
|
||||
FFBFFFBRLR
|
||||
FFBBFFFRRR
|
||||
BBFFFBFRLR
|
||||
FFFBBFBLRR
|
||||
BFFBBBBLLR
|
||||
BFBFFBBLRL
|
||||
BFFFFBFLLL
|
||||
BBBFFBFLLR
|
||||
FFBBBFFRLL
|
||||
BFFBBFBLLL
|
||||
BBBFBBFLLL
|
||||
BBFFBBFRRR
|
||||
2237
2020/input/2020/day6.txt
Normal file
2237
2020/input/2020/day6.txt
Normal file
File diff suppressed because it is too large
Load Diff
594
2020/input/2020/day7.txt
Normal file
594
2020/input/2020/day7.txt
Normal file
@@ -0,0 +1,594 @@
|
||||
wavy turquoise bags contain no other bags.
|
||||
vibrant beige bags contain 4 drab lime bags, 1 muted violet bag, 5 drab plum bags, 5 shiny silver bags.
|
||||
plaid green bags contain 2 pale olive bags, 1 dark chartreuse bag, 1 vibrant olive bag, 1 pale bronze bag.
|
||||
plaid fuchsia bags contain 5 dull teal bags, 4 dark beige bags, 4 shiny teal bags, 5 vibrant orange bags.
|
||||
vibrant coral bags contain 1 dotted blue bag.
|
||||
drab tan bags contain 5 drab maroon bags, 5 bright silver bags, 2 dim tan bags.
|
||||
light gray bags contain 3 dotted crimson bags, 3 dull chartreuse bags, 1 light maroon bag.
|
||||
mirrored tomato bags contain 5 clear orange bags, 2 striped violet bags.
|
||||
pale brown bags contain 1 faded fuchsia bag, 2 wavy orange bags, 1 mirrored coral bag, 5 dotted brown bags.
|
||||
muted maroon bags contain 5 drab gold bags, 2 vibrant aqua bags, 5 bright crimson bags.
|
||||
light purple bags contain 4 dim teal bags, 3 vibrant bronze bags, 2 dark chartreuse bags, 1 shiny green bag.
|
||||
muted white bags contain 3 wavy lime bags, 5 muted lavender bags, 1 pale salmon bag, 1 dotted red bag.
|
||||
plaid yellow bags contain 2 plaid gold bags, 2 faded lavender bags, 2 faded fuchsia bags, 3 faded gold bags.
|
||||
plaid white bags contain 1 dull cyan bag, 4 pale cyan bags, 1 clear red bag, 5 vibrant orange bags.
|
||||
wavy teal bags contain 5 wavy violet bags, 5 shiny silver bags.
|
||||
pale crimson bags contain 1 wavy white bag, 5 clear tomato bags, 2 dark plum bags, 3 bright turquoise bags.
|
||||
posh green bags contain 2 muted black bags, 3 light magenta bags.
|
||||
striped maroon bags contain 1 bright green bag, 4 dark coral bags.
|
||||
pale red bags contain 5 faded turquoise bags, 4 plaid crimson bags, 5 dark aqua bags.
|
||||
vibrant chartreuse bags contain 2 pale red bags.
|
||||
faded fuchsia bags contain no other bags.
|
||||
pale olive bags contain 3 striped blue bags, 5 faded magenta bags, 3 light white bags.
|
||||
striped tomato bags contain 4 faded plum bags.
|
||||
shiny cyan bags contain 1 clear tomato bag, 4 clear magenta bags, 3 plaid teal bags, 5 dotted indigo bags.
|
||||
plaid silver bags contain 3 dotted beige bags.
|
||||
posh teal bags contain 3 faded black bags, 2 vibrant lavender bags, 5 light lavender bags, 5 faded lime bags.
|
||||
clear gray bags contain 5 pale black bags, 2 dull salmon bags.
|
||||
bright white bags contain 2 shiny olive bags, 5 dim brown bags, 1 dull crimson bag.
|
||||
striped gold bags contain 3 mirrored yellow bags, 1 posh brown bag, 5 clear cyan bags, 3 striped tan bags.
|
||||
light black bags contain 2 light lavender bags, 2 dotted bronze bags.
|
||||
vibrant orange bags contain 3 posh plum bags, 5 light tan bags, 5 dim gold bags, 4 vibrant aqua bags.
|
||||
dark chartreuse bags contain 3 striped purple bags, 2 dull beige bags, 5 wavy brown bags.
|
||||
mirrored magenta bags contain 4 drab purple bags, 4 dotted brown bags, 2 light fuchsia bags.
|
||||
striped magenta bags contain 1 drab gray bag, 1 wavy yellow bag, 5 drab plum bags.
|
||||
dotted teal bags contain 4 pale indigo bags.
|
||||
plaid red bags contain 4 clear fuchsia bags, 2 vibrant brown bags.
|
||||
dotted green bags contain 2 striped teal bags, 3 muted bronze bags, 4 light red bags.
|
||||
vibrant purple bags contain 2 drab plum bags, 4 dim beige bags, 4 drab aqua bags.
|
||||
light indigo bags contain 1 dotted plum bag.
|
||||
wavy green bags contain 1 shiny aqua bag, 2 dark lavender bags.
|
||||
faded gray bags contain 2 plaid green bags.
|
||||
dull purple bags contain 4 dull salmon bags, 1 plaid chartreuse bag, 1 dull tan bag, 4 pale green bags.
|
||||
posh yellow bags contain 2 dim teal bags.
|
||||
pale orange bags contain 4 mirrored red bags, 2 dotted chartreuse bags, 2 light yellow bags, 3 posh red bags.
|
||||
dark tomato bags contain 1 light magenta bag, 4 light black bags, 2 vibrant aqua bags.
|
||||
light cyan bags contain 1 shiny red bag, 2 plaid green bags, 4 clear cyan bags, 5 wavy tomato bags.
|
||||
pale lavender bags contain 2 pale gray bags, 3 dotted violet bags, 2 striped lavender bags, 5 drab magenta bags.
|
||||
dim coral bags contain 4 bright black bags, 1 shiny tan bag, 1 faded chartreuse bag, 1 bright silver bag.
|
||||
muted purple bags contain 2 wavy yellow bags.
|
||||
pale chartreuse bags contain 3 dotted red bags, 4 striped salmon bags, 4 pale brown bags, 2 dull yellow bags.
|
||||
light red bags contain 3 bright crimson bags.
|
||||
bright green bags contain 2 plaid fuchsia bags, 5 light lavender bags, 3 dotted cyan bags.
|
||||
plaid purple bags contain 4 wavy tan bags, 5 plaid teal bags, 5 dull teal bags, 1 shiny gold bag.
|
||||
vibrant gray bags contain 1 dull beige bag.
|
||||
dotted orange bags contain 2 light green bags, 5 dotted brown bags, 4 pale blue bags.
|
||||
dull black bags contain 5 pale silver bags, 4 pale lavender bags.
|
||||
dull blue bags contain 1 striped turquoise bag, 2 dotted red bags, 5 dark white bags.
|
||||
clear turquoise bags contain 3 dim beige bags, 5 faded brown bags.
|
||||
pale magenta bags contain 1 dark violet bag, 1 dark yellow bag, 2 wavy aqua bags, 5 light silver bags.
|
||||
bright teal bags contain 1 dark beige bag, 1 pale gold bag, 1 dim magenta bag.
|
||||
pale plum bags contain 3 vibrant yellow bags, 1 dotted beige bag.
|
||||
dull lime bags contain 1 faded coral bag, 4 plaid gold bags, 3 drab white bags.
|
||||
vibrant olive bags contain 1 plaid teal bag, 1 faded tan bag.
|
||||
muted magenta bags contain 5 clear gold bags.
|
||||
dull olive bags contain 4 clear cyan bags, 1 dotted tan bag.
|
||||
dim orange bags contain 3 drab lime bags, 1 drab plum bag, 2 vibrant tomato bags, 1 plaid blue bag.
|
||||
wavy crimson bags contain 2 plaid gold bags, 3 light olive bags, 4 vibrant fuchsia bags.
|
||||
clear tan bags contain 3 dotted beige bags, 2 dark purple bags.
|
||||
plaid bronze bags contain 1 mirrored violet bag.
|
||||
muted brown bags contain 4 dotted indigo bags, 5 dull crimson bags.
|
||||
dull fuchsia bags contain 2 dotted gold bags, 2 striped violet bags, 1 clear lime bag, 3 shiny fuchsia bags.
|
||||
mirrored gold bags contain 2 mirrored purple bags, 4 plaid aqua bags.
|
||||
vibrant turquoise bags contain 1 light maroon bag, 3 dim teal bags, 1 dull brown bag.
|
||||
shiny green bags contain 2 plaid orange bags.
|
||||
dark crimson bags contain 1 striped purple bag, 4 vibrant salmon bags.
|
||||
bright gray bags contain 4 plaid blue bags, 1 faded lime bag, 4 pale salmon bags, 3 bright bronze bags.
|
||||
wavy salmon bags contain 1 wavy coral bag, 3 bright blue bags.
|
||||
faded blue bags contain 3 muted fuchsia bags, 1 plaid lavender bag, 3 posh brown bags.
|
||||
posh tomato bags contain 4 dim gold bags, 2 shiny gold bags.
|
||||
striped yellow bags contain 3 vibrant turquoise bags, 3 dim salmon bags, 4 vibrant yellow bags, 2 faded beige bags.
|
||||
light beige bags contain 5 striped purple bags, 3 muted gold bags.
|
||||
wavy indigo bags contain 1 muted chartreuse bag, 2 wavy purple bags, 2 mirrored coral bags, 4 muted teal bags.
|
||||
striped tan bags contain 4 light fuchsia bags, 2 dim chartreuse bags, 3 vibrant black bags, 1 muted black bag.
|
||||
pale fuchsia bags contain 5 vibrant aqua bags, 5 drab purple bags, 5 shiny olive bags, 5 drab indigo bags.
|
||||
pale cyan bags contain 5 dull teal bags.
|
||||
dull chartreuse bags contain 5 wavy brown bags.
|
||||
bright coral bags contain 3 clear orange bags, 3 shiny brown bags, 4 pale teal bags.
|
||||
light magenta bags contain 3 light white bags, 1 clear indigo bag, 3 vibrant salmon bags, 3 dark crimson bags.
|
||||
dull bronze bags contain 5 dotted gold bags, 4 dark olive bags, 3 vibrant magenta bags.
|
||||
light lime bags contain 4 vibrant cyan bags.
|
||||
muted aqua bags contain 3 dotted red bags, 2 wavy blue bags, 3 vibrant orange bags.
|
||||
light violet bags contain 3 light green bags.
|
||||
dotted red bags contain 1 muted teal bag, 4 striped tan bags, 3 wavy teal bags.
|
||||
pale purple bags contain 4 dotted cyan bags, 1 dim magenta bag.
|
||||
dim beige bags contain 5 dotted yellow bags, 4 faded magenta bags, 1 muted beige bag, 2 pale bronze bags.
|
||||
light bronze bags contain 5 faded bronze bags, 2 drab bronze bags, 5 dark gold bags, 2 light purple bags.
|
||||
wavy violet bags contain 5 light white bags, 3 light tan bags.
|
||||
vibrant aqua bags contain 3 wavy turquoise bags, 4 dull beige bags.
|
||||
pale bronze bags contain 5 light lavender bags, 4 dull beige bags, 3 bright crimson bags.
|
||||
bright salmon bags contain 5 mirrored bronze bags, 5 dull orange bags, 2 shiny salmon bags.
|
||||
muted blue bags contain 3 shiny yellow bags, 5 light yellow bags, 5 vibrant gold bags, 2 dotted coral bags.
|
||||
dotted silver bags contain 1 plaid fuchsia bag, 5 light beige bags, 4 drab lime bags.
|
||||
mirrored black bags contain 2 dull salmon bags.
|
||||
bright black bags contain 4 faded magenta bags.
|
||||
bright beige bags contain 2 mirrored salmon bags.
|
||||
bright indigo bags contain 4 clear brown bags, 3 bright green bags.
|
||||
mirrored lavender bags contain 3 shiny tan bags, 4 dark purple bags, 2 striped tan bags.
|
||||
light aqua bags contain 2 light magenta bags, 5 vibrant tan bags, 5 drab plum bags, 1 plaid tomato bag.
|
||||
mirrored maroon bags contain 4 vibrant tomato bags.
|
||||
posh turquoise bags contain 1 striped white bag, 3 dim lavender bags, 3 posh teal bags, 2 mirrored salmon bags.
|
||||
shiny gray bags contain 1 vibrant beige bag, 3 light tan bags, 4 wavy teal bags.
|
||||
wavy black bags contain 4 dark tomato bags, 3 dim gold bags, 4 dark beige bags.
|
||||
drab silver bags contain 2 light green bags, 3 light gold bags, 4 drab plum bags, 1 dotted yellow bag.
|
||||
pale violet bags contain 1 dull beige bag, 2 shiny teal bags, 1 light lavender bag, 3 mirrored red bags.
|
||||
dark blue bags contain 1 dotted indigo bag, 1 clear tomato bag.
|
||||
dull teal bags contain 5 vibrant salmon bags, 3 vibrant aqua bags, 5 wavy tan bags, 5 striped purple bags.
|
||||
faded tomato bags contain 2 shiny chartreuse bags, 4 clear orange bags, 5 bright orange bags.
|
||||
mirrored red bags contain 5 muted beige bags, 2 faded white bags.
|
||||
mirrored lime bags contain 4 posh crimson bags, 5 pale turquoise bags, 3 wavy blue bags.
|
||||
mirrored crimson bags contain 1 faded white bag, 2 dark crimson bags, 3 striped cyan bags.
|
||||
light teal bags contain 3 clear indigo bags, 1 wavy tan bag, 4 dim gold bags.
|
||||
wavy chartreuse bags contain 5 wavy plum bags, 2 shiny salmon bags, 3 clear olive bags.
|
||||
shiny black bags contain 2 drab aqua bags, 4 dull brown bags, 5 wavy silver bags, 1 vibrant brown bag.
|
||||
bright violet bags contain 2 striped magenta bags, 4 vibrant gray bags.
|
||||
muted tomato bags contain 1 drab turquoise bag.
|
||||
muted teal bags contain 3 dotted blue bags.
|
||||
dim cyan bags contain 3 dotted blue bags, 1 vibrant coral bag.
|
||||
striped fuchsia bags contain 1 shiny gold bag, 5 dark beige bags, 5 mirrored indigo bags.
|
||||
clear bronze bags contain 3 striped orange bags, 2 vibrant tomato bags.
|
||||
vibrant lavender bags contain 2 muted beige bags, 4 shiny teal bags, 4 dull beige bags.
|
||||
light olive bags contain 5 shiny yellow bags, 1 vibrant cyan bag.
|
||||
shiny fuchsia bags contain 4 dim brown bags, 2 dull chartreuse bags.
|
||||
plaid turquoise bags contain 3 bright green bags, 4 light fuchsia bags, 2 light lavender bags.
|
||||
shiny brown bags contain 5 mirrored plum bags.
|
||||
pale white bags contain 4 dull magenta bags, 1 posh purple bag, 4 pale olive bags, 4 wavy olive bags.
|
||||
pale yellow bags contain 1 bright blue bag.
|
||||
dark salmon bags contain 3 wavy turquoise bags, 1 dotted plum bag, 3 faded white bags, 5 dim tan bags.
|
||||
shiny crimson bags contain 5 faded coral bags.
|
||||
pale green bags contain 2 posh beige bags, 5 dark silver bags.
|
||||
dim gray bags contain 4 dull cyan bags, 2 muted salmon bags, 4 mirrored tan bags, 1 bright violet bag.
|
||||
dim blue bags contain 4 light orange bags, 4 wavy beige bags.
|
||||
mirrored cyan bags contain 3 pale cyan bags.
|
||||
dark aqua bags contain 2 striped blue bags, 5 light white bags, 4 drab gray bags.
|
||||
wavy tan bags contain no other bags.
|
||||
light tan bags contain 1 clear aqua bag.
|
||||
light silver bags contain 1 light green bag, 2 pale bronze bags, 1 bright crimson bag, 1 vibrant aqua bag.
|
||||
plaid tan bags contain 5 posh silver bags, 1 shiny beige bag.
|
||||
shiny white bags contain 1 pale olive bag.
|
||||
dotted brown bags contain 1 bright silver bag, 5 light tan bags, 4 light coral bags.
|
||||
shiny bronze bags contain 2 vibrant plum bags, 2 wavy teal bags, 1 bright red bag, 5 clear tomato bags.
|
||||
striped violet bags contain 5 vibrant gray bags, 3 dark maroon bags, 4 dotted fuchsia bags, 4 plaid purple bags.
|
||||
dull plum bags contain 4 dark gray bags, 1 wavy aqua bag, 2 muted aqua bags, 5 striped crimson bags.
|
||||
posh blue bags contain 1 dotted bronze bag, 5 muted indigo bags, 2 light tan bags.
|
||||
posh tan bags contain 4 shiny gold bags, 3 drab maroon bags.
|
||||
striped aqua bags contain 4 muted bronze bags, 5 bright blue bags, 1 wavy tan bag.
|
||||
shiny silver bags contain 1 light green bag.
|
||||
dark white bags contain 4 drab purple bags.
|
||||
dull green bags contain 5 wavy bronze bags, 5 faded white bags.
|
||||
clear chartreuse bags contain 3 dark gray bags.
|
||||
posh coral bags contain 2 shiny lime bags, 4 light blue bags, 3 muted bronze bags.
|
||||
faded magenta bags contain 1 dull maroon bag, 4 shiny teal bags, 1 plaid teal bag.
|
||||
drab brown bags contain 1 drab violet bag.
|
||||
pale salmon bags contain 4 plaid gray bags, 2 wavy violet bags.
|
||||
mirrored aqua bags contain 1 faded turquoise bag, 5 dull aqua bags.
|
||||
striped gray bags contain 5 dark maroon bags, 3 shiny plum bags.
|
||||
mirrored salmon bags contain 4 clear cyan bags, 2 vibrant olive bags, 2 striped silver bags, 3 muted lavender bags.
|
||||
wavy purple bags contain 1 shiny beige bag.
|
||||
plaid indigo bags contain 1 plaid plum bag.
|
||||
plaid gray bags contain 5 pale blue bags, 3 shiny gold bags.
|
||||
bright yellow bags contain 2 drab bronze bags, 3 drab teal bags.
|
||||
drab red bags contain 4 drab indigo bags, 1 mirrored blue bag, 2 dull aqua bags, 4 light magenta bags.
|
||||
dull white bags contain 2 muted black bags, 1 dim beige bag, 1 dark beige bag.
|
||||
clear silver bags contain 5 muted bronze bags, 1 muted tan bag, 3 light aqua bags, 1 wavy fuchsia bag.
|
||||
dark black bags contain 2 pale fuchsia bags, 5 pale brown bags, 5 drab black bags.
|
||||
mirrored silver bags contain 4 drab plum bags, 3 shiny white bags, 5 muted crimson bags, 5 dull aqua bags.
|
||||
dim tomato bags contain 3 drab red bags, 1 drab lime bag, 4 striped gray bags.
|
||||
faded bronze bags contain 5 clear indigo bags, 2 dotted blue bags.
|
||||
striped crimson bags contain 1 plaid tomato bag, 2 dull yellow bags, 3 plaid purple bags.
|
||||
wavy olive bags contain 4 mirrored red bags, 4 drab indigo bags.
|
||||
dotted turquoise bags contain 2 mirrored lavender bags, 4 light maroon bags, 2 pale teal bags, 1 mirrored crimson bag.
|
||||
muted violet bags contain 5 shiny olive bags.
|
||||
bright orange bags contain 4 pale tan bags, 1 striped fuchsia bag, 5 shiny olive bags.
|
||||
striped turquoise bags contain 1 posh salmon bag, 5 shiny indigo bags, 4 wavy violet bags.
|
||||
dull indigo bags contain 3 plaid plum bags, 4 faded plum bags, 3 dull violet bags.
|
||||
posh black bags contain 4 clear brown bags, 4 vibrant cyan bags, 1 light white bag.
|
||||
shiny orange bags contain 5 striped purple bags, 3 muted beige bags.
|
||||
striped plum bags contain 5 dull salmon bags, 3 dull orange bags, 1 clear lime bag, 3 mirrored indigo bags.
|
||||
clear white bags contain 4 wavy crimson bags, 3 plaid magenta bags.
|
||||
pale tan bags contain 5 muted indigo bags.
|
||||
dark red bags contain 3 bright magenta bags, 1 muted salmon bag, 4 vibrant gray bags, 5 clear green bags.
|
||||
dark yellow bags contain 3 dim teal bags.
|
||||
clear aqua bags contain no other bags.
|
||||
vibrant white bags contain 2 drab yellow bags, 4 vibrant aqua bags, 2 plaid maroon bags.
|
||||
posh lime bags contain 5 vibrant black bags.
|
||||
clear teal bags contain 1 shiny olive bag, 5 bright aqua bags, 4 bright violet bags.
|
||||
dotted indigo bags contain 2 muted fuchsia bags, 3 mirrored gray bags.
|
||||
posh olive bags contain 5 clear maroon bags, 2 dim teal bags, 2 drab plum bags, 4 shiny olive bags.
|
||||
dark coral bags contain 4 clear red bags.
|
||||
dark olive bags contain 4 vibrant black bags.
|
||||
faded olive bags contain 2 bright gray bags, 5 dull white bags.
|
||||
dotted purple bags contain 1 faded brown bag, 5 dark purple bags.
|
||||
faded plum bags contain 2 pale brown bags, 4 dark aqua bags.
|
||||
bright plum bags contain 2 vibrant brown bags, 1 bright black bag, 1 dotted gold bag.
|
||||
faded lavender bags contain 4 clear violet bags, 4 striped purple bags.
|
||||
faded silver bags contain 4 dotted blue bags, 2 light purple bags, 1 bright chartreuse bag, 3 striped white bags.
|
||||
bright cyan bags contain 5 dotted lime bags, 5 shiny gray bags, 1 faded orange bag, 5 clear indigo bags.
|
||||
plaid tomato bags contain 1 clear violet bag, 3 muted beige bags.
|
||||
wavy aqua bags contain 1 light tan bag.
|
||||
dotted gold bags contain 5 mirrored indigo bags, 5 dull tan bags.
|
||||
faded teal bags contain 5 plaid black bags, 2 clear turquoise bags.
|
||||
striped white bags contain 2 dull aqua bags, 1 mirrored violet bag, 4 vibrant salmon bags.
|
||||
mirrored violet bags contain 2 vibrant salmon bags, 1 clear brown bag.
|
||||
drab magenta bags contain 3 muted lime bags, 2 bright orange bags.
|
||||
pale teal bags contain 3 light black bags, 4 dim black bags, 2 muted gray bags.
|
||||
dark teal bags contain 5 dark tomato bags, 4 dull teal bags, 5 striped white bags, 5 plaid aqua bags.
|
||||
dim purple bags contain 5 wavy magenta bags, 2 muted fuchsia bags, 5 mirrored bronze bags.
|
||||
clear violet bags contain 5 wavy turquoise bags, 5 light black bags, 1 mirrored indigo bag, 2 faded white bags.
|
||||
dim indigo bags contain 3 dull teal bags.
|
||||
dotted olive bags contain 4 dark red bags, 2 mirrored beige bags.
|
||||
posh aqua bags contain 1 posh blue bag, 4 dotted black bags, 4 pale tomato bags.
|
||||
clear orange bags contain 1 striped magenta bag, 3 wavy aqua bags.
|
||||
plaid cyan bags contain 5 vibrant lavender bags, 2 light gold bags, 2 wavy orange bags, 4 bright turquoise bags.
|
||||
mirrored green bags contain 4 plaid fuchsia bags.
|
||||
dark silver bags contain 3 light coral bags.
|
||||
wavy silver bags contain 5 plaid yellow bags, 5 pale orange bags.
|
||||
plaid crimson bags contain 4 vibrant salmon bags, 4 vibrant blue bags, 1 light teal bag, 3 bright crimson bags.
|
||||
mirrored bronze bags contain 1 dark coral bag, 2 clear orange bags, 4 plaid orange bags, 2 vibrant gray bags.
|
||||
faded aqua bags contain 5 light white bags, 3 drab gray bags, 1 plaid beige bag.
|
||||
drab yellow bags contain 1 dotted black bag, 2 dim silver bags.
|
||||
dark beige bags contain 4 wavy tan bags, 5 light lavender bags, 5 dotted bronze bags.
|
||||
clear green bags contain 5 shiny purple bags, 5 light teal bags, 5 pale bronze bags.
|
||||
dotted lavender bags contain 4 wavy orange bags, 4 dull chartreuse bags.
|
||||
bright chartreuse bags contain 2 dotted cyan bags, 3 pale olive bags, 4 vibrant salmon bags.
|
||||
faded red bags contain 3 dull cyan bags, 3 drab indigo bags, 5 light green bags, 4 dark lime bags.
|
||||
plaid brown bags contain 2 dotted salmon bags, 3 striped silver bags, 1 light blue bag.
|
||||
dull beige bags contain no other bags.
|
||||
dim violet bags contain 3 striped lavender bags, 5 dotted coral bags, 1 clear blue bag.
|
||||
vibrant red bags contain 1 dark coral bag, 3 light gold bags.
|
||||
faded violet bags contain 3 pale gold bags.
|
||||
muted salmon bags contain 3 wavy turquoise bags.
|
||||
vibrant gold bags contain 2 shiny teal bags.
|
||||
dull coral bags contain 3 posh gold bags, 4 wavy olive bags.
|
||||
mirrored fuchsia bags contain 5 wavy lime bags.
|
||||
dotted plum bags contain 3 bright bronze bags, 3 light coral bags, 5 mirrored orange bags, 4 plaid gray bags.
|
||||
dim fuchsia bags contain 4 light indigo bags, 5 faded red bags, 5 plaid orange bags.
|
||||
dull brown bags contain 2 dim gold bags.
|
||||
faded indigo bags contain 3 wavy olive bags, 1 shiny green bag.
|
||||
pale coral bags contain 5 faded crimson bags.
|
||||
light orange bags contain 3 bright gold bags, 1 striped magenta bag, 4 plaid lavender bags, 5 light green bags.
|
||||
clear salmon bags contain 3 dim tan bags, 1 light lavender bag.
|
||||
vibrant indigo bags contain 1 dark beige bag, 2 posh purple bags.
|
||||
clear cyan bags contain 5 posh brown bags.
|
||||
dull red bags contain 3 drab gold bags, 3 dark aqua bags, 5 dim maroon bags.
|
||||
dim red bags contain 5 faded black bags, 2 shiny lime bags.
|
||||
dark indigo bags contain 5 dull green bags, 2 striped white bags, 3 dotted indigo bags.
|
||||
pale tomato bags contain 4 vibrant gold bags.
|
||||
dim turquoise bags contain 4 plaid tomato bags, 2 plaid gray bags, 4 shiny violet bags.
|
||||
dotted yellow bags contain 5 dotted plum bags, 3 muted beige bags, 4 light fuchsia bags, 1 wavy olive bag.
|
||||
dim gold bags contain 3 muted beige bags.
|
||||
mirrored orange bags contain 5 drab maroon bags, 4 dull teal bags, 1 faded tan bag, 2 dark aqua bags.
|
||||
light chartreuse bags contain 4 vibrant gold bags, 5 dark silver bags, 3 pale purple bags.
|
||||
posh silver bags contain 5 dotted silver bags, 4 dark chartreuse bags, 1 striped magenta bag.
|
||||
vibrant black bags contain 5 muted red bags, 1 pale purple bag, 2 clear indigo bags, 4 faded magenta bags.
|
||||
faded maroon bags contain 2 clear cyan bags, 4 wavy orange bags, 2 shiny blue bags.
|
||||
bright lavender bags contain 5 dull chartreuse bags.
|
||||
drab black bags contain 1 posh plum bag, 5 mirrored maroon bags, 3 dark yellow bags.
|
||||
drab gray bags contain 4 clear violet bags, 3 mirrored red bags, 1 light silver bag, 1 wavy turquoise bag.
|
||||
faded turquoise bags contain 2 light tan bags, 5 faded coral bags.
|
||||
dark purple bags contain 5 pale cyan bags.
|
||||
muted beige bags contain no other bags.
|
||||
dull maroon bags contain 2 wavy turquoise bags, 5 light lavender bags, 5 muted beige bags.
|
||||
bright tomato bags contain 3 plaid blue bags.
|
||||
dim crimson bags contain 3 drab turquoise bags, 2 faded crimson bags, 2 plaid chartreuse bags.
|
||||
clear magenta bags contain 3 light green bags, 5 dotted red bags, 1 mirrored indigo bag, 1 dim brown bag.
|
||||
dotted aqua bags contain 5 clear crimson bags, 1 wavy orange bag.
|
||||
dark fuchsia bags contain 1 dull maroon bag.
|
||||
faded salmon bags contain 2 wavy yellow bags, 3 faded plum bags.
|
||||
muted chartreuse bags contain 5 light gold bags, 1 bright bronze bag, 5 light beige bags, 4 light black bags.
|
||||
muted lavender bags contain 3 mirrored coral bags.
|
||||
drab fuchsia bags contain 3 plaid brown bags.
|
||||
dim plum bags contain 4 vibrant brown bags, 3 plaid beige bags, 3 dark crimson bags, 4 bright teal bags.
|
||||
shiny magenta bags contain 1 muted black bag.
|
||||
wavy magenta bags contain 2 faded lavender bags, 1 bright gray bag, 3 pale olive bags.
|
||||
mirrored plum bags contain 5 muted maroon bags.
|
||||
wavy plum bags contain 5 dark crimson bags.
|
||||
striped lavender bags contain 4 vibrant yellow bags, 2 vibrant lavender bags.
|
||||
faded beige bags contain 4 pale indigo bags, 5 vibrant tomato bags.
|
||||
shiny gold bags contain 4 drab gray bags, 4 light coral bags.
|
||||
dotted beige bags contain 5 drab maroon bags, 1 shiny gold bag, 3 light lavender bags.
|
||||
dull yellow bags contain 3 pale bronze bags, 1 bright silver bag.
|
||||
muted green bags contain 3 faded red bags, 2 plaid green bags, 3 plaid black bags, 1 light yellow bag.
|
||||
vibrant silver bags contain 5 striped purple bags, 3 shiny olive bags, 4 vibrant lavender bags.
|
||||
dim green bags contain 4 vibrant gold bags, 5 muted maroon bags, 1 plaid aqua bag, 2 posh silver bags.
|
||||
faded lime bags contain 2 shiny white bags.
|
||||
bright bronze bags contain 5 muted gold bags, 3 light black bags.
|
||||
shiny yellow bags contain 5 light green bags, 5 wavy brown bags.
|
||||
dark cyan bags contain 5 light teal bags, 1 posh yellow bag, 3 shiny aqua bags.
|
||||
striped blue bags contain 1 muted gold bag, 4 dull maroon bags, 3 clear red bags, 5 faded fuchsia bags.
|
||||
dim tan bags contain 1 bright tan bag.
|
||||
shiny red bags contain 3 plaid turquoise bags, 1 dotted cyan bag, 1 pale fuchsia bag.
|
||||
vibrant brown bags contain 5 dim magenta bags, 4 drab white bags.
|
||||
dull turquoise bags contain 2 bright orange bags, 4 bright gray bags, 3 dim chartreuse bags.
|
||||
dark bronze bags contain 3 striped green bags, 2 wavy tan bags, 2 faded lime bags, 3 bright olive bags.
|
||||
striped green bags contain 4 light black bags, 2 drab bronze bags, 4 dotted bronze bags, 3 plaid orange bags.
|
||||
dark brown bags contain 5 drab indigo bags, 3 plaid white bags, 1 pale lime bag.
|
||||
dotted black bags contain 4 dull beige bags, 4 drab lavender bags.
|
||||
striped cyan bags contain 2 vibrant orange bags, 3 clear violet bags, 2 mirrored gray bags.
|
||||
clear tomato bags contain 5 shiny gold bags, 1 dim chartreuse bag, 4 dark crimson bags, 5 shiny white bags.
|
||||
light white bags contain 3 pale violet bags, 4 drab plum bags, 4 drab gray bags, 1 vibrant lavender bag.
|
||||
plaid black bags contain 4 vibrant orange bags, 5 bright gray bags.
|
||||
drab salmon bags contain 4 faded coral bags.
|
||||
shiny maroon bags contain 3 pale black bags, 2 bright magenta bags.
|
||||
striped black bags contain 1 plaid fuchsia bag, 4 plaid black bags, 1 mirrored beige bag.
|
||||
muted bronze bags contain 5 faded red bags, 5 plaid green bags.
|
||||
bright tan bags contain 1 wavy yellow bag, 5 light fuchsia bags, 5 plaid teal bags.
|
||||
plaid gold bags contain 5 faded black bags, 1 vibrant black bag.
|
||||
wavy tomato bags contain 5 plaid fuchsia bags, 2 mirrored violet bags, 3 dark yellow bags, 1 bright gold bag.
|
||||
faded tan bags contain 5 vibrant salmon bags, 5 plaid teal bags, 4 clear aqua bags, 2 pale violet bags.
|
||||
light crimson bags contain 3 mirrored tomato bags, 5 plaid green bags.
|
||||
wavy bronze bags contain 1 light teal bag.
|
||||
faded yellow bags contain 3 clear beige bags, 4 bright bronze bags.
|
||||
muted gold bags contain 5 plaid teal bags, 2 faded fuchsia bags, 4 bright crimson bags.
|
||||
shiny tan bags contain 5 dark salmon bags, 5 light red bags.
|
||||
bright gold bags contain 2 faded chartreuse bags, 2 dim green bags, 3 striped cyan bags.
|
||||
pale turquoise bags contain 1 pale tan bag, 5 dark violet bags.
|
||||
wavy orange bags contain 5 plaid teal bags, 1 pale bronze bag, 4 wavy tan bags, 1 clear red bag.
|
||||
dim silver bags contain 3 dark lime bags, 1 dotted beige bag.
|
||||
faded cyan bags contain 2 dull maroon bags, 5 clear tan bags, 1 dull coral bag, 2 posh lavender bags.
|
||||
dim white bags contain 1 dull maroon bag, 3 dull brown bags.
|
||||
vibrant bronze bags contain 5 faded chartreuse bags.
|
||||
dotted fuchsia bags contain 4 vibrant salmon bags, 2 faded white bags.
|
||||
faded gold bags contain 2 dark maroon bags, 2 bright chartreuse bags, 1 dull brown bag.
|
||||
dim brown bags contain 3 dull yellow bags, 4 faded chartreuse bags, 5 vibrant silver bags.
|
||||
light yellow bags contain 2 striped silver bags.
|
||||
striped coral bags contain 1 muted blue bag, 1 dim aqua bag, 4 posh red bags, 5 plaid lime bags.
|
||||
dark magenta bags contain 2 pale violet bags, 2 vibrant tomato bags, 5 clear orange bags.
|
||||
posh indigo bags contain 2 clear red bags, 4 clear violet bags, 2 shiny chartreuse bags, 5 dull white bags.
|
||||
light tomato bags contain 4 clear indigo bags.
|
||||
light plum bags contain 2 mirrored maroon bags.
|
||||
drab violet bags contain 5 dark aqua bags, 1 vibrant magenta bag.
|
||||
pale gray bags contain 1 striped lime bag, 4 clear bronze bags.
|
||||
dark plum bags contain 2 dark olive bags.
|
||||
plaid lavender bags contain 4 pale brown bags.
|
||||
mirrored olive bags contain 1 faded coral bag.
|
||||
drab green bags contain 2 dull silver bags, 2 clear purple bags, 3 posh violet bags, 2 light blue bags.
|
||||
bright maroon bags contain 4 faded yellow bags, 4 dotted bronze bags, 2 dark brown bags.
|
||||
striped purple bags contain 2 faded fuchsia bags, 5 posh plum bags.
|
||||
wavy gray bags contain 4 dark violet bags, 4 plaid orange bags.
|
||||
drab plum bags contain 3 light lavender bags, 1 striped blue bag, 5 bright crimson bags.
|
||||
faded orange bags contain 4 light teal bags, 4 dim chartreuse bags, 2 vibrant yellow bags.
|
||||
dim salmon bags contain 2 pale coral bags, 1 drab aqua bag.
|
||||
muted silver bags contain 1 clear chartreuse bag, 2 clear tan bags, 5 dotted tan bags, 4 clear black bags.
|
||||
muted yellow bags contain 3 wavy blue bags, 1 striped lavender bag.
|
||||
wavy gold bags contain 5 faded gold bags, 1 shiny green bag, 1 mirrored cyan bag.
|
||||
dull gold bags contain 1 striped green bag.
|
||||
bright brown bags contain 4 drab plum bags, 4 pale violet bags, 5 vibrant blue bags.
|
||||
bright crimson bags contain 2 wavy tan bags, 4 shiny teal bags.
|
||||
mirrored gray bags contain 2 dull beige bags, 4 light white bags, 5 pale brown bags.
|
||||
dull tan bags contain 4 dim magenta bags, 1 light teal bag.
|
||||
mirrored yellow bags contain 1 drab lavender bag, 4 shiny gold bags, 3 drab turquoise bags, 2 light silver bags.
|
||||
muted indigo bags contain 5 mirrored coral bags, 3 dark crimson bags.
|
||||
dull aqua bags contain 4 drab lime bags, 3 shiny crimson bags, 1 drab salmon bag.
|
||||
dim aqua bags contain 2 shiny lavender bags, 5 pale coral bags.
|
||||
shiny chartreuse bags contain 1 clear maroon bag, 4 shiny blue bags.
|
||||
dotted magenta bags contain 3 light olive bags.
|
||||
faded green bags contain 4 faded beige bags, 5 dotted gold bags, 5 striped lavender bags, 5 wavy blue bags.
|
||||
drab orange bags contain 3 muted fuchsia bags.
|
||||
dim magenta bags contain 1 shiny orange bag.
|
||||
shiny olive bags contain 2 wavy aqua bags.
|
||||
dark orange bags contain 1 clear black bag, 1 faded gray bag.
|
||||
light lavender bags contain no other bags.
|
||||
bright turquoise bags contain 2 dull beige bags, 5 shiny teal bags, 5 posh brown bags, 5 dark beige bags.
|
||||
faded purple bags contain 2 dark white bags, 2 pale salmon bags.
|
||||
drab olive bags contain 1 dark silver bag, 4 plaid yellow bags, 3 drab gold bags, 2 mirrored yellow bags.
|
||||
dull gray bags contain 3 vibrant turquoise bags, 5 faded chartreuse bags.
|
||||
striped bronze bags contain 3 faded turquoise bags, 2 vibrant gray bags, 3 dotted beige bags, 3 dull beige bags.
|
||||
wavy fuchsia bags contain 2 shiny purple bags, 2 plaid crimson bags, 1 dark cyan bag.
|
||||
pale aqua bags contain 4 dotted tan bags, 1 dim yellow bag, 5 shiny lime bags.
|
||||
pale silver bags contain 2 shiny brown bags.
|
||||
shiny aqua bags contain 1 pale salmon bag, 5 faded chartreuse bags, 1 plaid aqua bag, 4 shiny silver bags.
|
||||
posh brown bags contain 5 vibrant orange bags, 4 bright silver bags, 5 wavy orange bags, 3 dim chartreuse bags.
|
||||
striped lime bags contain 5 drab violet bags, 4 light turquoise bags, 2 bright turquoise bags.
|
||||
muted tan bags contain 2 striped purple bags, 4 posh yellow bags.
|
||||
drab purple bags contain 2 clear red bags.
|
||||
plaid magenta bags contain 2 pale blue bags, 5 plaid crimson bags.
|
||||
mirrored tan bags contain 3 pale purple bags.
|
||||
light blue bags contain 4 light tan bags.
|
||||
clear black bags contain 2 pale blue bags, 4 dim gold bags, 2 vibrant gold bags.
|
||||
light gold bags contain 1 wavy turquoise bag, 3 drab plum bags, 1 clear violet bag.
|
||||
bright olive bags contain 3 light lavender bags, 1 faded tan bag, 3 shiny gold bags, 1 dotted cyan bag.
|
||||
dark maroon bags contain 4 muted gold bags, 2 shiny yellow bags.
|
||||
wavy lime bags contain 3 plaid green bags, 5 mirrored silver bags, 4 mirrored green bags, 3 dotted beige bags.
|
||||
drab white bags contain 3 clear red bags, 3 bright silver bags, 4 posh red bags, 2 shiny blue bags.
|
||||
clear lime bags contain 4 dotted orange bags.
|
||||
vibrant maroon bags contain 2 dull orange bags, 5 vibrant crimson bags.
|
||||
pale black bags contain 1 pale cyan bag, 5 dim tan bags, 4 shiny purple bags, 4 faded fuchsia bags.
|
||||
vibrant tomato bags contain 2 mirrored orange bags.
|
||||
dotted gray bags contain 3 dotted purple bags.
|
||||
drab gold bags contain 4 shiny gold bags.
|
||||
mirrored teal bags contain 3 shiny magenta bags, 3 mirrored beige bags, 3 dotted silver bags, 5 mirrored indigo bags.
|
||||
posh lavender bags contain 2 wavy teal bags, 4 striped violet bags, 1 vibrant gold bag.
|
||||
dark lavender bags contain 3 light blue bags, 2 muted beige bags, 3 clear magenta bags, 1 light tan bag.
|
||||
muted cyan bags contain 4 dull gold bags, 1 dim yellow bag, 4 striped cyan bags, 2 dim gold bags.
|
||||
dim maroon bags contain 5 shiny purple bags.
|
||||
shiny purple bags contain 5 pale violet bags, 2 light fuchsia bags, 2 mirrored red bags.
|
||||
vibrant lime bags contain 4 bright orange bags, 1 posh beige bag.
|
||||
vibrant teal bags contain 2 posh turquoise bags, 3 pale tomato bags, 3 dark bronze bags.
|
||||
posh fuchsia bags contain 3 striped plum bags, 2 drab aqua bags.
|
||||
dotted violet bags contain 5 plaid black bags, 1 clear salmon bag, 2 dull chartreuse bags.
|
||||
clear gold bags contain 2 dull violet bags, 3 muted white bags.
|
||||
dull cyan bags contain 4 pale violet bags, 2 light gold bags, 4 dark tomato bags.
|
||||
posh beige bags contain 5 mirrored cyan bags, 5 dotted red bags, 3 clear purple bags, 3 posh white bags.
|
||||
dotted maroon bags contain 3 pale orange bags, 1 striped black bag, 4 faded fuchsia bags.
|
||||
dotted tomato bags contain 5 striped magenta bags, 4 striped orange bags, 3 muted teal bags, 3 bright black bags.
|
||||
drab teal bags contain 5 striped tan bags, 4 dull green bags, 5 muted coral bags, 1 clear red bag.
|
||||
vibrant magenta bags contain 5 bright orange bags, 4 mirrored gray bags, 1 faded tan bag, 4 faded brown bags.
|
||||
posh crimson bags contain 5 light lime bags, 1 faded brown bag, 2 posh red bags.
|
||||
dull lavender bags contain 4 clear green bags, 5 wavy orange bags, 5 posh green bags, 3 plaid orange bags.
|
||||
wavy yellow bags contain 2 light teal bags.
|
||||
dotted bronze bags contain 3 clear red bags, 4 posh plum bags, 4 light lavender bags, 4 faded fuchsia bags.
|
||||
dim olive bags contain 2 dotted chartreuse bags.
|
||||
dark gray bags contain 3 shiny olive bags.
|
||||
posh salmon bags contain 1 pale purple bag, 2 clear tomato bags, 4 shiny gold bags.
|
||||
shiny coral bags contain 3 dark olive bags, 2 dull fuchsia bags, 1 dull gold bag.
|
||||
vibrant green bags contain 2 light fuchsia bags, 5 vibrant violet bags, 3 dotted blue bags.
|
||||
pale lime bags contain 4 vibrant gold bags, 5 dotted yellow bags.
|
||||
vibrant yellow bags contain 5 clear violet bags, 1 dark maroon bag.
|
||||
pale beige bags contain 4 faded red bags, 4 striped green bags.
|
||||
dim bronze bags contain 5 posh chartreuse bags, 5 light white bags.
|
||||
clear fuchsia bags contain 5 posh yellow bags, 4 faded fuchsia bags.
|
||||
faded chartreuse bags contain 5 drab purple bags, 1 wavy olive bag, 3 light black bags, 1 dotted brown bag.
|
||||
mirrored turquoise bags contain 1 faded fuchsia bag, 2 mirrored blue bags.
|
||||
light maroon bags contain 4 dotted blue bags, 4 muted gold bags, 3 faded lavender bags.
|
||||
muted crimson bags contain 5 posh bronze bags.
|
||||
mirrored blue bags contain 1 faded lavender bag, 5 bright chartreuse bags, 4 dotted brown bags.
|
||||
striped brown bags contain 2 clear cyan bags, 4 vibrant orange bags, 5 shiny tan bags.
|
||||
muted orange bags contain 3 dotted black bags, 4 clear beige bags, 2 plaid beige bags, 1 mirrored coral bag.
|
||||
clear beige bags contain 3 wavy tan bags, 5 dark aqua bags.
|
||||
bright silver bags contain 3 striped purple bags.
|
||||
muted plum bags contain 5 light purple bags, 1 light lavender bag, 2 drab maroon bags, 1 posh black bag.
|
||||
vibrant salmon bags contain 1 shiny teal bag.
|
||||
dotted chartreuse bags contain 4 vibrant gold bags.
|
||||
shiny lime bags contain 3 dotted crimson bags, 3 striped crimson bags.
|
||||
wavy brown bags contain 1 pale violet bag, 3 light beige bags, 2 wavy aqua bags, 4 dim teal bags.
|
||||
clear yellow bags contain 3 dotted tan bags.
|
||||
bright red bags contain 1 dim tomato bag, 5 clear tan bags, 2 posh red bags, 5 mirrored yellow bags.
|
||||
drab tomato bags contain 1 drab yellow bag.
|
||||
dull crimson bags contain 1 dotted brown bag, 2 bright gray bags, 4 dim tan bags.
|
||||
shiny beige bags contain 2 plaid teal bags.
|
||||
dotted coral bags contain 4 plaid teal bags, 2 pale turquoise bags, 4 dark lime bags, 2 pale purple bags.
|
||||
shiny plum bags contain 5 dull coral bags, 1 shiny gold bag.
|
||||
light coral bags contain 2 pale bronze bags, 1 clear aqua bag.
|
||||
vibrant cyan bags contain 1 muted fuchsia bag, 4 pale tan bags, 1 shiny green bag, 1 dotted blue bag.
|
||||
bright purple bags contain 4 faded white bags.
|
||||
mirrored chartreuse bags contain 2 shiny orange bags.
|
||||
light brown bags contain 4 striped violet bags, 4 striped purple bags, 3 wavy yellow bags, 2 drab blue bags.
|
||||
clear brown bags contain 1 clear indigo bag, 2 dark coral bags.
|
||||
vibrant fuchsia bags contain 4 dull tan bags, 4 vibrant bronze bags, 1 light white bag, 5 vibrant tomato bags.
|
||||
clear crimson bags contain 5 muted tomato bags.
|
||||
muted red bags contain 2 dull beige bags, 2 dark turquoise bags, 1 dark fuchsia bag.
|
||||
dull salmon bags contain 2 bright tan bags, 5 faded white bags, 4 muted beige bags, 1 dull cyan bag.
|
||||
drab lavender bags contain 1 dark chartreuse bag.
|
||||
vibrant plum bags contain 1 dark violet bag, 2 mirrored red bags, 3 muted purple bags, 5 dull blue bags.
|
||||
drab maroon bags contain 3 plaid teal bags, 4 muted beige bags, 4 posh gold bags, 5 mirrored coral bags.
|
||||
posh magenta bags contain 4 wavy tomato bags, 3 wavy beige bags.
|
||||
striped olive bags contain 3 shiny plum bags, 4 plaid gold bags.
|
||||
vibrant crimson bags contain 2 dim chartreuse bags.
|
||||
drab lime bags contain 1 vibrant aqua bag.
|
||||
wavy maroon bags contain 2 dark tan bags, 4 faded brown bags, 4 dim silver bags, 1 muted lime bag.
|
||||
dull tomato bags contain 2 dotted bronze bags, 5 vibrant maroon bags, 4 plaid tan bags.
|
||||
dim teal bags contain 5 muted beige bags, 2 mirrored indigo bags, 4 vibrant lavender bags.
|
||||
wavy white bags contain 1 muted white bag, 1 dim chartreuse bag.
|
||||
bright lime bags contain 3 dull gold bags, 2 dull indigo bags, 4 drab teal bags.
|
||||
plaid aqua bags contain 4 light lavender bags, 4 posh gold bags, 3 wavy violet bags, 5 muted chartreuse bags.
|
||||
mirrored purple bags contain 3 dark lavender bags, 3 clear salmon bags, 1 plaid white bag, 1 striped violet bag.
|
||||
plaid maroon bags contain 4 dotted red bags, 1 mirrored coral bag, 5 muted indigo bags, 1 clear turquoise bag.
|
||||
dark turquoise bags contain 4 bright crimson bags, 2 dotted bronze bags, 2 pale violet bags, 5 wavy aqua bags.
|
||||
dull silver bags contain 2 wavy olive bags, 5 shiny violet bags.
|
||||
muted olive bags contain 5 plaid beige bags, 3 dark brown bags, 1 clear black bag, 4 faded red bags.
|
||||
drab indigo bags contain 1 pale violet bag.
|
||||
muted lime bags contain 5 striped violet bags, 2 plaid lavender bags.
|
||||
drab blue bags contain 1 pale tomato bag.
|
||||
drab bronze bags contain 3 vibrant blue bags, 1 vibrant bronze bag.
|
||||
muted gray bags contain 4 dim chartreuse bags.
|
||||
striped teal bags contain 4 dark coral bags.
|
||||
light green bags contain 2 plaid teal bags, 5 pale bronze bags, 3 dull teal bags.
|
||||
plaid salmon bags contain 3 bright chartreuse bags.
|
||||
dotted blue bags contain 4 drab plum bags, 1 light tan bag.
|
||||
dark violet bags contain 5 dark coral bags, 5 dotted lavender bags, 5 pale brown bags, 1 vibrant lavender bag.
|
||||
pale gold bags contain 1 bright silver bag, 2 dark cyan bags, 1 dull tan bag, 1 plaid blue bag.
|
||||
light turquoise bags contain 3 drab turquoise bags, 1 dull tan bag, 3 muted indigo bags, 5 dotted fuchsia bags.
|
||||
plaid blue bags contain 3 pale violet bags, 4 dotted brown bags.
|
||||
bright magenta bags contain 4 shiny brown bags, 4 wavy violet bags, 3 dark aqua bags, 2 bright turquoise bags.
|
||||
clear maroon bags contain 4 posh plum bags.
|
||||
posh red bags contain 5 plaid cyan bags, 4 clear orange bags.
|
||||
posh purple bags contain 5 plaid cyan bags, 1 drab lavender bag, 3 pale purple bags, 4 light coral bags.
|
||||
dim lime bags contain 2 striped beige bags, 2 dark blue bags.
|
||||
shiny indigo bags contain 2 vibrant black bags, 2 wavy orange bags.
|
||||
posh gold bags contain 5 dull beige bags, 1 shiny teal bag.
|
||||
wavy beige bags contain 2 dark beige bags, 4 muted chartreuse bags, 2 dim lavender bags, 2 mirrored indigo bags.
|
||||
dim lavender bags contain 2 vibrant aqua bags.
|
||||
mirrored beige bags contain 2 posh red bags, 3 pale olive bags, 3 dull brown bags.
|
||||
clear indigo bags contain 1 shiny teal bag, 1 mirrored indigo bag.
|
||||
dim chartreuse bags contain 5 bright tan bags.
|
||||
plaid coral bags contain 2 clear green bags.
|
||||
wavy cyan bags contain 2 drab blue bags, 5 dotted coral bags, 3 mirrored beige bags.
|
||||
dotted crimson bags contain 1 muted tan bag, 4 dull maroon bags, 2 striped crimson bags.
|
||||
drab cyan bags contain 1 dull cyan bag, 3 pale cyan bags, 4 faded aqua bags, 4 clear tan bags.
|
||||
wavy coral bags contain 4 wavy plum bags, 5 plaid beige bags, 5 pale tan bags.
|
||||
pale maroon bags contain 5 pale tan bags.
|
||||
shiny blue bags contain 3 light coral bags, 4 bright olive bags.
|
||||
plaid orange bags contain 2 dim white bags, 3 shiny silver bags, 3 pale violet bags.
|
||||
dark tan bags contain 2 vibrant olive bags, 3 plaid turquoise bags, 2 dull chartreuse bags, 4 dull teal bags.
|
||||
posh cyan bags contain 5 posh orange bags, 5 shiny brown bags.
|
||||
clear red bags contain no other bags.
|
||||
light fuchsia bags contain 4 dark beige bags, 1 light black bag, 1 striped blue bag.
|
||||
striped beige bags contain 2 bright silver bags, 2 faded indigo bags, 1 plaid turquoise bag, 3 shiny plum bags.
|
||||
wavy lavender bags contain 4 posh black bags, 1 dotted teal bag, 4 drab purple bags.
|
||||
dotted cyan bags contain 5 dull yellow bags, 5 light beige bags, 2 vibrant aqua bags, 5 dark beige bags.
|
||||
drab crimson bags contain 5 dark magenta bags.
|
||||
plaid olive bags contain 1 vibrant crimson bag, 5 dim bronze bags, 1 striped black bag, 1 drab brown bag.
|
||||
dim yellow bags contain 3 plaid gray bags, 5 vibrant salmon bags, 4 vibrant olive bags.
|
||||
striped indigo bags contain 3 mirrored coral bags, 2 vibrant bronze bags, 3 dull brown bags.
|
||||
dark green bags contain 3 shiny teal bags, 5 pale chartreuse bags, 5 dull teal bags, 5 striped silver bags.
|
||||
drab aqua bags contain 5 dark aqua bags, 5 dotted blue bags, 1 pale violet bag, 1 pale bronze bag.
|
||||
striped orange bags contain 3 striped green bags, 4 muted beige bags, 2 clear aqua bags, 3 dark crimson bags.
|
||||
striped silver bags contain 1 pale cyan bag, 5 drab gold bags, 3 bright turquoise bags, 4 light gold bags.
|
||||
bright blue bags contain 4 light black bags, 1 plaid salmon bag.
|
||||
striped red bags contain 1 vibrant plum bag, 5 dull blue bags, 1 dull olive bag.
|
||||
posh white bags contain 3 drab bronze bags, 4 bright crimson bags.
|
||||
drab turquoise bags contain 4 striped crimson bags.
|
||||
clear lavender bags contain 4 faded magenta bags, 1 mirrored gray bag, 4 wavy yellow bags, 1 dotted cyan bag.
|
||||
drab chartreuse bags contain 1 shiny gray bag.
|
||||
clear purple bags contain 1 shiny brown bag, 2 bright gray bags, 5 clear salmon bags.
|
||||
dull magenta bags contain 1 posh cyan bag, 3 muted indigo bags, 1 dim lavender bag.
|
||||
posh chartreuse bags contain 4 wavy violet bags.
|
||||
posh maroon bags contain 4 striped gray bags.
|
||||
clear blue bags contain 3 faded lime bags, 2 pale purple bags.
|
||||
dark gold bags contain 2 dull beige bags, 3 plaid blue bags.
|
||||
muted coral bags contain 4 dark gold bags.
|
||||
bright aqua bags contain 3 muted crimson bags.
|
||||
dull orange bags contain 3 posh gold bags.
|
||||
shiny turquoise bags contain 3 dark brown bags, 5 shiny red bags, 3 muted beige bags.
|
||||
mirrored brown bags contain 2 light orange bags, 5 drab coral bags, 2 wavy lime bags.
|
||||
striped chartreuse bags contain 1 dark lavender bag, 4 pale salmon bags, 4 dotted violet bags, 4 clear tomato bags.
|
||||
shiny salmon bags contain 4 dim magenta bags.
|
||||
bright fuchsia bags contain 4 muted chartreuse bags, 3 mirrored green bags.
|
||||
shiny tomato bags contain 5 clear gray bags, 2 drab silver bags, 3 clear green bags.
|
||||
muted turquoise bags contain 5 shiny orange bags, 1 mirrored tan bag.
|
||||
vibrant tan bags contain 1 faded magenta bag, 5 drab plum bags.
|
||||
posh gray bags contain 2 posh magenta bags.
|
||||
dark lime bags contain 5 clear aqua bags, 3 posh plum bags.
|
||||
plaid violet bags contain 2 light bronze bags, 1 light green bag, 1 striped gold bag.
|
||||
vibrant blue bags contain 2 wavy yellow bags, 4 dim magenta bags, 1 drab maroon bag, 4 dotted brown bags.
|
||||
faded brown bags contain 2 pale blue bags, 4 bright olive bags, 1 bright bronze bag.
|
||||
striped salmon bags contain 4 light green bags, 4 wavy orange bags, 3 mirrored coral bags.
|
||||
plaid lime bags contain 1 bright green bag, 2 light indigo bags.
|
||||
plaid chartreuse bags contain 4 vibrant green bags, 5 dotted coral bags, 2 muted gray bags, 4 bright purple bags.
|
||||
light salmon bags contain 5 vibrant maroon bags, 3 dark lime bags, 5 drab tan bags, 1 striped cyan bag.
|
||||
muted fuchsia bags contain 4 light silver bags, 3 light teal bags, 3 muted gold bags.
|
||||
clear plum bags contain 5 light turquoise bags.
|
||||
posh orange bags contain 5 wavy tan bags, 4 dark turquoise bags.
|
||||
dotted tan bags contain 2 plaid teal bags.
|
||||
shiny teal bags contain no other bags.
|
||||
posh violet bags contain 2 vibrant tomato bags, 4 bright orange bags, 3 dotted red bags, 5 pale silver bags.
|
||||
dotted lime bags contain 5 wavy tan bags, 2 dark tomato bags, 5 mirrored gray bags, 2 light aqua bags.
|
||||
posh plum bags contain no other bags.
|
||||
mirrored white bags contain 4 clear gold bags, 1 dark teal bag.
|
||||
pale indigo bags contain 4 shiny magenta bags, 1 shiny maroon bag.
|
||||
drab beige bags contain 1 muted plum bag, 5 posh turquoise bags, 2 vibrant fuchsia bags.
|
||||
faded black bags contain 5 wavy black bags.
|
||||
plaid beige bags contain 2 posh purple bags, 4 pale olive bags, 3 striped green bags, 5 bright orange bags.
|
||||
faded white bags contain 4 clear red bags, 4 faded fuchsia bags, 1 dull beige bag.
|
||||
shiny violet bags contain 3 shiny green bags, 5 wavy brown bags.
|
||||
wavy blue bags contain 2 light teal bags, 4 dull silver bags, 2 bright black bags, 4 dull tan bags.
|
||||
wavy red bags contain 4 dark silver bags, 5 dotted chartreuse bags, 2 clear salmon bags, 2 striped tan bags.
|
||||
shiny lavender bags contain 2 muted bronze bags.
|
||||
faded coral bags contain 5 dotted chartreuse bags, 2 vibrant silver bags, 2 wavy black bags.
|
||||
clear coral bags contain 4 muted fuchsia bags.
|
||||
mirrored coral bags contain 1 vibrant lavender bag.
|
||||
dim black bags contain 2 bright olive bags, 1 dull teal bag, 4 shiny purple bags.
|
||||
pale blue bags contain 1 light black bag, 2 light white bags, 1 dull maroon bag, 5 plaid teal bags.
|
||||
plaid plum bags contain 3 muted coral bags, 1 dim brown bag, 2 plaid aqua bags, 1 vibrant blue bag.
|
||||
muted black bags contain 5 light blue bags, 3 clear salmon bags.
|
||||
dotted white bags contain 3 shiny salmon bags, 1 faded maroon bag.
|
||||
drab coral bags contain 3 striped gold bags, 4 shiny aqua bags, 5 wavy red bags.
|
||||
dotted salmon bags contain 4 drab black bags, 2 light aqua bags.
|
||||
mirrored indigo bags contain 3 wavy orange bags, 5 posh plum bags.
|
||||
vibrant violet bags contain 1 striped lavender bag, 1 muted purple bag, 2 drab silver bags, 5 pale olive bags.
|
||||
plaid teal bags contain 4 shiny teal bags, 2 wavy turquoise bags, 2 vibrant aqua bags.
|
||||
dull violet bags contain 5 light coral bags, 1 vibrant tan bag.
|
||||
faded crimson bags contain 3 dark chartreuse bags, 2 vibrant cyan bags, 3 mirrored cyan bags.
|
||||
posh bronze bags contain 4 plaid lavender bags, 3 shiny gold bags, 5 mirrored coral bags, 2 shiny indigo bags.
|
||||
clear olive bags contain 2 muted gray bags, 2 dark red bags, 5 clear brown bags, 5 bright silver bags.
|
||||
612
2020/input/2020/day8.txt
Normal file
612
2020/input/2020/day8.txt
Normal file
@@ -0,0 +1,612 @@
|
||||
acc +18
|
||||
nop +222
|
||||
acc -16
|
||||
acc +28
|
||||
jmp +475
|
||||
acc -6
|
||||
jmp +584
|
||||
acc -12
|
||||
acc -8
|
||||
jmp +554
|
||||
acc -9
|
||||
acc +12
|
||||
acc -16
|
||||
acc +27
|
||||
jmp +336
|
||||
acc -4
|
||||
jmp +214
|
||||
acc +38
|
||||
jmp +61
|
||||
acc +3
|
||||
acc +28
|
||||
acc +5
|
||||
acc -19
|
||||
jmp +584
|
||||
nop +206
|
||||
jmp +506
|
||||
acc +36
|
||||
jmp +133
|
||||
acc +20
|
||||
acc +43
|
||||
acc -18
|
||||
jmp +409
|
||||
acc +24
|
||||
jmp +131
|
||||
acc -12
|
||||
acc +7
|
||||
acc +7
|
||||
jmp +454
|
||||
acc +37
|
||||
acc -6
|
||||
nop +558
|
||||
acc +31
|
||||
jmp +124
|
||||
acc -15
|
||||
nop +201
|
||||
acc -7
|
||||
jmp +297
|
||||
acc +3
|
||||
nop +517
|
||||
jmp +221
|
||||
jmp +211
|
||||
acc +28
|
||||
acc +35
|
||||
jmp +5
|
||||
acc +31
|
||||
nop +325
|
||||
acc -15
|
||||
jmp +116
|
||||
jmp +1
|
||||
nop +333
|
||||
acc -2
|
||||
acc -5
|
||||
jmp +138
|
||||
acc +19
|
||||
acc +9
|
||||
jmp +180
|
||||
acc +18
|
||||
jmp +228
|
||||
jmp +495
|
||||
jmp +382
|
||||
acc +20
|
||||
nop +414
|
||||
nop +139
|
||||
acc +33
|
||||
jmp +171
|
||||
acc -10
|
||||
jmp +41
|
||||
acc -2
|
||||
jmp +80
|
||||
acc +20
|
||||
nop +451
|
||||
acc +2
|
||||
acc +24
|
||||
jmp +102
|
||||
acc +1
|
||||
acc -11
|
||||
acc +9
|
||||
acc +38
|
||||
jmp -73
|
||||
acc +17
|
||||
acc +16
|
||||
acc +12
|
||||
acc +43
|
||||
jmp +168
|
||||
jmp +286
|
||||
acc +6
|
||||
acc +6
|
||||
jmp +271
|
||||
acc -17
|
||||
acc -5
|
||||
acc +1
|
||||
jmp -50
|
||||
acc -9
|
||||
acc +6
|
||||
acc -2
|
||||
acc +33
|
||||
jmp +385
|
||||
acc +18
|
||||
acc +24
|
||||
jmp +370
|
||||
acc -5
|
||||
acc +23
|
||||
acc +6
|
||||
jmp +98
|
||||
acc -10
|
||||
acc -16
|
||||
jmp +329
|
||||
nop +41
|
||||
jmp +463
|
||||
nop +224
|
||||
acc +35
|
||||
jmp +345
|
||||
acc +34
|
||||
acc -18
|
||||
acc +5
|
||||
jmp +177
|
||||
nop -57
|
||||
nop -80
|
||||
acc +20
|
||||
jmp -12
|
||||
acc +24
|
||||
acc +39
|
||||
jmp +363
|
||||
jmp +253
|
||||
acc -14
|
||||
acc +0
|
||||
acc +22
|
||||
jmp +118
|
||||
acc +43
|
||||
acc -2
|
||||
jmp +300
|
||||
acc -14
|
||||
acc +8
|
||||
acc +47
|
||||
jmp +271
|
||||
jmp +420
|
||||
acc +33
|
||||
acc +15
|
||||
acc +20
|
||||
acc +25
|
||||
jmp +84
|
||||
acc +41
|
||||
jmp +420
|
||||
acc +25
|
||||
jmp +238
|
||||
jmp +1
|
||||
acc +14
|
||||
jmp +415
|
||||
jmp +68
|
||||
jmp +262
|
||||
acc +34
|
||||
jmp +346
|
||||
acc +39
|
||||
jmp +56
|
||||
jmp +364
|
||||
jmp -133
|
||||
acc +13
|
||||
jmp +1
|
||||
acc +33
|
||||
jmp +408
|
||||
acc +29
|
||||
acc -4
|
||||
jmp +319
|
||||
jmp +106
|
||||
jmp +228
|
||||
acc -8
|
||||
acc +8
|
||||
acc +22
|
||||
jmp -146
|
||||
jmp +223
|
||||
acc +27
|
||||
nop +191
|
||||
acc +49
|
||||
jmp +331
|
||||
jmp +39
|
||||
jmp -170
|
||||
acc +28
|
||||
acc -6
|
||||
acc +50
|
||||
jmp +268
|
||||
acc +41
|
||||
nop +254
|
||||
acc +28
|
||||
jmp +269
|
||||
jmp +140
|
||||
acc +10
|
||||
nop +131
|
||||
acc +3
|
||||
jmp -40
|
||||
jmp +373
|
||||
acc +47
|
||||
jmp -91
|
||||
acc -19
|
||||
jmp +300
|
||||
acc -2
|
||||
jmp +1
|
||||
acc +44
|
||||
acc -11
|
||||
jmp +306
|
||||
acc +33
|
||||
jmp -15
|
||||
acc +9
|
||||
jmp +1
|
||||
jmp +144
|
||||
acc +40
|
||||
nop +184
|
||||
nop -75
|
||||
nop +228
|
||||
jmp +296
|
||||
acc +22
|
||||
nop +364
|
||||
jmp -214
|
||||
jmp +18
|
||||
jmp +375
|
||||
acc +22
|
||||
jmp -67
|
||||
acc +8
|
||||
acc -17
|
||||
jmp +174
|
||||
jmp -99
|
||||
nop -45
|
||||
acc +7
|
||||
jmp -213
|
||||
jmp -218
|
||||
acc +50
|
||||
nop +52
|
||||
nop +98
|
||||
jmp -142
|
||||
acc +18
|
||||
jmp +252
|
||||
acc +36
|
||||
jmp -194
|
||||
acc +1
|
||||
nop -53
|
||||
jmp -127
|
||||
jmp +327
|
||||
acc +7
|
||||
acc -9
|
||||
acc +39
|
||||
nop -127
|
||||
jmp +84
|
||||
jmp -117
|
||||
nop -29
|
||||
acc +43
|
||||
jmp -216
|
||||
acc +25
|
||||
acc +16
|
||||
acc +40
|
||||
nop +122
|
||||
jmp +140
|
||||
jmp +180
|
||||
acc +42
|
||||
acc -5
|
||||
acc -14
|
||||
jmp -84
|
||||
jmp -31
|
||||
acc +37
|
||||
acc -11
|
||||
jmp -217
|
||||
jmp +210
|
||||
jmp +170
|
||||
nop +301
|
||||
jmp +309
|
||||
acc +6
|
||||
jmp +135
|
||||
acc +6
|
||||
nop -123
|
||||
acc +17
|
||||
jmp +315
|
||||
acc -1
|
||||
nop -46
|
||||
nop -58
|
||||
nop -59
|
||||
jmp +202
|
||||
acc +48
|
||||
acc +38
|
||||
jmp +86
|
||||
acc -4
|
||||
acc +33
|
||||
acc +28
|
||||
jmp -50
|
||||
nop +43
|
||||
acc +38
|
||||
acc +13
|
||||
jmp +33
|
||||
acc +4
|
||||
acc +6
|
||||
jmp -78
|
||||
acc +22
|
||||
acc +7
|
||||
acc -9
|
||||
jmp -56
|
||||
acc +30
|
||||
nop +54
|
||||
nop -81
|
||||
nop +198
|
||||
jmp +252
|
||||
jmp +1
|
||||
acc +6
|
||||
acc -10
|
||||
acc +29
|
||||
jmp -242
|
||||
jmp +1
|
||||
acc +42
|
||||
acc +34
|
||||
acc +22
|
||||
jmp +231
|
||||
acc +29
|
||||
acc -10
|
||||
jmp -161
|
||||
acc +37
|
||||
acc +9
|
||||
jmp -77
|
||||
acc -15
|
||||
acc +32
|
||||
acc +32
|
||||
jmp -6
|
||||
acc +0
|
||||
nop -124
|
||||
nop +174
|
||||
jmp +20
|
||||
acc +45
|
||||
acc +24
|
||||
jmp -13
|
||||
acc +6
|
||||
acc -10
|
||||
acc +23
|
||||
acc -15
|
||||
jmp +34
|
||||
acc +5
|
||||
acc +38
|
||||
acc +42
|
||||
jmp -116
|
||||
acc +0
|
||||
acc +8
|
||||
jmp -243
|
||||
acc -18
|
||||
acc +25
|
||||
acc +1
|
||||
jmp +158
|
||||
nop +65
|
||||
jmp +1
|
||||
jmp +151
|
||||
acc +12
|
||||
acc +12
|
||||
jmp +1
|
||||
jmp -305
|
||||
jmp +29
|
||||
jmp -263
|
||||
acc +33
|
||||
jmp +1
|
||||
nop +142
|
||||
jmp +78
|
||||
acc +41
|
||||
nop -141
|
||||
acc -9
|
||||
acc +5
|
||||
jmp -245
|
||||
jmp +41
|
||||
acc +16
|
||||
nop -83
|
||||
jmp -28
|
||||
nop -149
|
||||
acc +38
|
||||
jmp -15
|
||||
acc +7
|
||||
nop -329
|
||||
acc +5
|
||||
acc +21
|
||||
jmp -7
|
||||
acc -19
|
||||
jmp -38
|
||||
acc +5
|
||||
acc +3
|
||||
acc +10
|
||||
jmp -181
|
||||
jmp -240
|
||||
acc +19
|
||||
acc +15
|
||||
acc +31
|
||||
acc -11
|
||||
jmp -340
|
||||
acc +12
|
||||
acc +46
|
||||
jmp +127
|
||||
acc +12
|
||||
acc +31
|
||||
acc +30
|
||||
jmp -158
|
||||
acc -10
|
||||
jmp -374
|
||||
jmp +50
|
||||
acc +43
|
||||
nop +42
|
||||
acc +19
|
||||
jmp -232
|
||||
acc -14
|
||||
acc -4
|
||||
jmp +95
|
||||
acc +23
|
||||
acc +49
|
||||
acc +31
|
||||
nop -139
|
||||
jmp -272
|
||||
jmp -141
|
||||
acc +26
|
||||
acc -8
|
||||
jmp +173
|
||||
nop +145
|
||||
nop +133
|
||||
jmp +164
|
||||
acc +7
|
||||
jmp +23
|
||||
acc -4
|
||||
acc +48
|
||||
jmp -138
|
||||
acc +4
|
||||
jmp -389
|
||||
nop +156
|
||||
acc +44
|
||||
acc +40
|
||||
jmp +146
|
||||
nop -247
|
||||
acc +44
|
||||
jmp +1
|
||||
acc +28
|
||||
jmp +95
|
||||
acc +13
|
||||
acc +2
|
||||
jmp -254
|
||||
acc +24
|
||||
jmp +122
|
||||
acc +39
|
||||
acc +0
|
||||
jmp -12
|
||||
jmp -179
|
||||
nop -44
|
||||
nop +100
|
||||
acc -19
|
||||
nop -47
|
||||
jmp -107
|
||||
acc +32
|
||||
acc +33
|
||||
acc +42
|
||||
acc +6
|
||||
jmp -366
|
||||
jmp -122
|
||||
acc +2
|
||||
nop -443
|
||||
nop +72
|
||||
jmp -381
|
||||
jmp -446
|
||||
jmp -332
|
||||
acc -7
|
||||
acc +45
|
||||
jmp -355
|
||||
acc +27
|
||||
acc -4
|
||||
acc +3
|
||||
jmp +96
|
||||
acc +45
|
||||
jmp -402
|
||||
acc +45
|
||||
acc -3
|
||||
acc +22
|
||||
jmp -141
|
||||
acc +29
|
||||
acc -1
|
||||
jmp +29
|
||||
acc -1
|
||||
acc -10
|
||||
jmp -208
|
||||
acc +6
|
||||
nop -196
|
||||
jmp -218
|
||||
acc -12
|
||||
acc +49
|
||||
nop -137
|
||||
jmp -430
|
||||
acc +21
|
||||
jmp -110
|
||||
nop -287
|
||||
acc -3
|
||||
jmp -42
|
||||
jmp -487
|
||||
acc -16
|
||||
acc -1
|
||||
acc +7
|
||||
acc +39
|
||||
jmp -119
|
||||
jmp +1
|
||||
acc +9
|
||||
jmp -23
|
||||
acc +27
|
||||
jmp -300
|
||||
acc +12
|
||||
jmp -440
|
||||
acc +2
|
||||
acc +38
|
||||
acc +12
|
||||
jmp -84
|
||||
acc +25
|
||||
acc -14
|
||||
jmp -418
|
||||
acc -15
|
||||
acc +48
|
||||
jmp +1
|
||||
nop -383
|
||||
jmp -365
|
||||
acc +47
|
||||
jmp -193
|
||||
acc +23
|
||||
jmp -235
|
||||
jmp +1
|
||||
acc -4
|
||||
acc +35
|
||||
nop -64
|
||||
jmp -87
|
||||
acc +32
|
||||
jmp -339
|
||||
jmp -479
|
||||
acc -4
|
||||
acc +32
|
||||
acc -10
|
||||
jmp -77
|
||||
acc +0
|
||||
acc +47
|
||||
acc +41
|
||||
jmp -308
|
||||
acc -8
|
||||
acc -9
|
||||
jmp -229
|
||||
acc -14
|
||||
acc +24
|
||||
nop -380
|
||||
acc +49
|
||||
jmp -174
|
||||
acc -11
|
||||
nop -69
|
||||
jmp +3
|
||||
acc -14
|
||||
jmp -89
|
||||
jmp -301
|
||||
acc +46
|
||||
acc +8
|
||||
nop -156
|
||||
acc +44
|
||||
jmp +1
|
||||
jmp +26
|
||||
acc +17
|
||||
acc +23
|
||||
acc +6
|
||||
jmp -4
|
||||
jmp -97
|
||||
jmp -324
|
||||
acc +2
|
||||
jmp -27
|
||||
nop -195
|
||||
acc +3
|
||||
acc -13
|
||||
acc +15
|
||||
jmp -19
|
||||
acc +30
|
||||
nop -318
|
||||
jmp +19
|
||||
nop -72
|
||||
jmp -315
|
||||
acc +4
|
||||
nop +6
|
||||
jmp -384
|
||||
jmp -505
|
||||
jmp -512
|
||||
acc +33
|
||||
jmp -168
|
||||
jmp -443
|
||||
nop -519
|
||||
acc +7
|
||||
acc +41
|
||||
acc +15
|
||||
jmp -269
|
||||
nop -539
|
||||
jmp -416
|
||||
jmp -326
|
||||
nop -221
|
||||
acc +14
|
||||
jmp -186
|
||||
acc -1
|
||||
jmp -295
|
||||
acc +29
|
||||
acc +43
|
||||
nop -436
|
||||
nop -421
|
||||
jmp -123
|
||||
acc +13
|
||||
acc -11
|
||||
acc +12
|
||||
jmp -155
|
||||
acc +9
|
||||
acc -16
|
||||
acc -15
|
||||
nop -380
|
||||
jmp +1
|
||||
1000
2020/input/2020/day9.txt
Normal file
1000
2020/input/2020/day9.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
2020/scripts/update-readme.sh
Executable file
10
2020/scripts/update-readme.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
MAX_DAY=$(ls src/day* | tr -d 'a-z/. ' | sort -n | tail -1)
|
||||
(
|
||||
echo "# Results"
|
||||
echo
|
||||
echo "\`\`\`"
|
||||
cargo run --release
|
||||
echo "\`\`\`"
|
||||
echo
|
||||
) > README.md
|
||||
238
2020/src/day10.rs
Normal file
238
2020/src/day10.rs
Normal file
@@ -0,0 +1,238 @@
|
||||
//! --- Day 10: Adapter Array ---
|
||||
//! Patched into the aircraft's data port, you discover weather forecasts of a massive tropical storm. Before you can figure out whether it will impact your vacation plans, however, your device suddenly turns off!
|
||||
//!
|
||||
//! Its battery is dead.
|
||||
//!
|
||||
//! You'll need to plug it in. There's only one problem: the charging outlet near your seat produces the wrong number of jolts. Always prepared, you make a list of all of the joltage adapters in your bag.
|
||||
//!
|
||||
//! Each of your joltage adapters is rated for a specific output joltage (your puzzle input). Any given adapter can take an input 1, 2, or 3 jolts lower than its rating and still produce its rated output joltage.
|
||||
//!
|
||||
//! In addition, your device has a built-in joltage adapter rated for 3 jolts higher than the highest-rated adapter in your bag. (If your adapter list were 3, 9, and 6, your device's built-in adapter would be rated for 12 jolts.)
|
||||
//!
|
||||
//! Treat the charging outlet near your seat as having an effective joltage rating of 0.
|
||||
//!
|
||||
//! Since you have some time to kill, you might as well test all of your adapters. Wouldn't want to get to your resort and realize you can't even charge your device!
|
||||
//!
|
||||
//! If you use every adapter in your bag at once, what is the distribution of joltage differences between the charging outlet, the adapters, and your device?
|
||||
//!
|
||||
//! For example, suppose that in your bag, you have adapters with the following joltage ratings:
|
||||
//!
|
||||
//! 16
|
||||
//! 10
|
||||
//! 15
|
||||
//! 5
|
||||
//! 1
|
||||
//! 11
|
||||
//! 7
|
||||
//! 19
|
||||
//! 6
|
||||
//! 12
|
||||
//! 4
|
||||
//! With these adapters, your device's built-in joltage adapter would be rated for 19 + 3 = 22 jolts, 3 higher than the highest-rated adapter.
|
||||
//!
|
||||
//! Because adapters can only connect to a source 1-3 jolts lower than its rating, in order to use every adapter, you'd need to choose them like this:
|
||||
//!
|
||||
//! The charging outlet has an effective rating of 0 jolts, so the only adapters that could connect to it directly would need to have a joltage rating of 1, 2, or 3 jolts. Of these, only one you have is an adapter rated 1 jolt (difference of 1).
|
||||
//! From your 1-jolt rated adapter, the only choice is your 4-jolt rated adapter (difference of 3).
|
||||
//! From the 4-jolt rated adapter, the adapters rated 5, 6, or 7 are valid choices. However, in order to not skip any adapters, you have to pick the adapter rated 5 jolts (difference of 1).
|
||||
//! Similarly, the next choices would need to be the adapter rated 6 and then the adapter rated 7 (with difference of 1 and 1).
|
||||
//! The only adapter that works with the 7-jolt rated adapter is the one rated 10 jolts (difference of 3).
|
||||
//! From 10, the choices are 11 or 12; choose 11 (difference of 1) and then 12 (difference of 1).
|
||||
//! After 12, only valid adapter has a rating of 15 (difference of 3), then 16 (difference of 1), then 19 (difference of 3).
|
||||
//! Finally, your device's built-in adapter is always 3 higher than the highest adapter, so its rating is 22 jolts (always a difference of 3).
|
||||
//! In this example, when using every adapter, there are 7 differences of 1 jolt and 5 differences of 3 jolts.
|
||||
//!
|
||||
//! Here is a larger example:
|
||||
//!
|
||||
//! 28
|
||||
//! 33
|
||||
//! 18
|
||||
//! 42
|
||||
//! 31
|
||||
//! 14
|
||||
//! 46
|
||||
//! 20
|
||||
//! 48
|
||||
//! 47
|
||||
//! 24
|
||||
//! 23
|
||||
//! 49
|
||||
//! 45
|
||||
//! 19
|
||||
//! 38
|
||||
//! 39
|
||||
//! 11
|
||||
//! 1
|
||||
//! 32
|
||||
//! 25
|
||||
//! 35
|
||||
//! 8
|
||||
//! 17
|
||||
//! 7
|
||||
//! 9
|
||||
//! 4
|
||||
//! 2
|
||||
//! 34
|
||||
//! 10
|
||||
//! 3
|
||||
//! In this larger example, in a chain that uses all of the adapters, there are 22 differences of 1 jolt and 10 differences of 3 jolts.
|
||||
//!
|
||||
//! Find a chain that uses all of your adapters to connect the charging outlet to your device's built-in adapter and count the joltage differences between the charging outlet, the adapters, and your device. What is the number of 1-jolt differences multiplied by the number of 3-jolt differences?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! To completely determine whether you have enough adapters, you'll need to figure out how many different ways they can be arranged. Every arrangement needs to connect the charging outlet to your device. The previous rules about when adapters can successfully connect still apply.
|
||||
//!
|
||||
//! The first example above (the one that starts with 16, 10, 15) supports the following arrangements:
|
||||
//!
|
||||
//! (0), 1, 4, 5, 6, 7, 10, 11, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 5, 6, 7, 10, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 5, 7, 10, 11, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 5, 7, 10, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 6, 7, 10, 11, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 6, 7, 10, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 7, 10, 11, 12, 15, 16, 19, (22)
|
||||
//! (0), 1, 4, 7, 10, 12, 15, 16, 19, (22)
|
||||
//! (The charging outlet and your device's built-in adapter are shown in parentheses.) Given the adapters from the first example, the total number of arrangements that connect the charging outlet to your device is 8.
|
||||
//!
|
||||
//! The second example above (the one that starts with 28, 33, 18) has many arrangements. Here are a few:
|
||||
//!
|
||||
//! (0), 1, 2, 3, 4, 7, 8, 9, 10, 11, 14, 17, 18, 19, 20, 23, 24, 25, 28, 31,
|
||||
//! 32, 33, 34, 35, 38, 39, 42, 45, 46, 47, 48, 49, (52)
|
||||
//!
|
||||
//! (0), 1, 2, 3, 4, 7, 8, 9, 10, 11, 14, 17, 18, 19, 20, 23, 24, 25, 28, 31,
|
||||
//! 32, 33, 34, 35, 38, 39, 42, 45, 46, 47, 49, (52)
|
||||
//!
|
||||
//! (0), 1, 2, 3, 4, 7, 8, 9, 10, 11, 14, 17, 18, 19, 20, 23, 24, 25, 28, 31,
|
||||
//! 32, 33, 34, 35, 38, 39, 42, 45, 46, 48, 49, (52)
|
||||
//!
|
||||
//! (0), 1, 2, 3, 4, 7, 8, 9, 10, 11, 14, 17, 18, 19, 20, 23, 24, 25, 28, 31,
|
||||
//! 32, 33, 34, 35, 38, 39, 42, 45, 46, 49, (52)
|
||||
//!
|
||||
//! (0), 1, 2, 3, 4, 7, 8, 9, 10, 11, 14, 17, 18, 19, 20, 23, 24, 25, 28, 31,
|
||||
//! 32, 33, 34, 35, 38, 39, 42, 45, 47, 48, 49, (52)
|
||||
//!
|
||||
//! (0), 3, 4, 7, 10, 11, 14, 17, 20, 23, 25, 28, 31, 34, 35, 38, 39, 42, 45,
|
||||
//! 46, 48, 49, (52)
|
||||
//!
|
||||
//! (0), 3, 4, 7, 10, 11, 14, 17, 20, 23, 25, 28, 31, 34, 35, 38, 39, 42, 45,
|
||||
//! 46, 49, (52)
|
||||
//!
|
||||
//! (0), 3, 4, 7, 10, 11, 14, 17, 20, 23, 25, 28, 31, 34, 35, 38, 39, 42, 45,
|
||||
//! 47, 48, 49, (52)
|
||||
//!
|
||||
//! (0), 3, 4, 7, 10, 11, 14, 17, 20, 23, 25, 28, 31, 34, 35, 38, 39, 42, 45,
|
||||
//! 47, 49, (52)
|
||||
//!
|
||||
//! (0), 3, 4, 7, 10, 11, 14, 17, 20, 23, 25, 28, 31, 34, 35, 38, 39, 42, 45,
|
||||
//! 48, 49, (52)
|
||||
//! In total, this set of adapters can connect the charging outlet to your device in 19208 distinct arrangements.
|
||||
//!
|
||||
//! You glance back down at your bag and try to remember why you brought so many adapters; there must be more than a trillion valid ways to arrange them! Surely, there must be an efficient way to count the arrangements.
|
||||
//!
|
||||
//! What is the total number of distinct ways you can arrange the adapters to connect the charging outlet to your device?
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[aoc_generator(day10)]
|
||||
fn parse(input: &str) -> Vec<usize> {
|
||||
let mut jolts: Vec<_> = input.split('\n').map(|s| s.parse().unwrap()).collect();
|
||||
// Add outlet
|
||||
jolts.push(0);
|
||||
// Add device power adapter
|
||||
jolts.push(jolts.iter().max().unwrap() + 3);
|
||||
jolts.sort();
|
||||
jolts
|
||||
}
|
||||
|
||||
#[aoc(day10, part1)]
|
||||
fn solution1(jolts: &[usize]) -> usize {
|
||||
let (one, three) = jolts.windows(2).fold((0, 0), |(one, three), pair| {
|
||||
let first = pair[0];
|
||||
let second = pair[1];
|
||||
match second - first {
|
||||
1 => (one + 1, three),
|
||||
3 => (one, three + 1),
|
||||
d => panic!(format!("unexpected diff: {} - {} = {}", second, first, d)),
|
||||
}
|
||||
});
|
||||
one * three
|
||||
}
|
||||
|
||||
#[aoc(day10, part2)]
|
||||
fn solution2(jolts: &[usize]) -> usize {
|
||||
// count_permutations(jolts)
|
||||
// Store permutations at each node.
|
||||
let mut paths = vec![1; jolts.len()];
|
||||
|
||||
jolts.iter().enumerate().skip(1).for_each(|(cur, jolt)| {
|
||||
let p = (cur.saturating_sub(3)..cur)
|
||||
.filter(|idx| (jolt - jolts[*idx]) <= 3)
|
||||
.map(|idx| paths[idx])
|
||||
.sum();
|
||||
paths[cur] = p;
|
||||
});
|
||||
paths[paths.len() - 1]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// 1 4 5 6 7 10 11 12 15 16 19
|
||||
const INPUT1: &'static str = r#"16
|
||||
10
|
||||
15
|
||||
5
|
||||
1
|
||||
11
|
||||
7
|
||||
19
|
||||
6
|
||||
12
|
||||
4"#;
|
||||
|
||||
// 1 2 3 4 7 8 9 10 11 14 17 18 19 20 23 24 25 31 32 33 34 35 38 39 42 45 46 47 48 49
|
||||
const INPUT2: &'static str = r#"28
|
||||
33
|
||||
18
|
||||
42
|
||||
31
|
||||
14
|
||||
46
|
||||
20
|
||||
48
|
||||
47
|
||||
24
|
||||
23
|
||||
49
|
||||
45
|
||||
19
|
||||
38
|
||||
39
|
||||
11
|
||||
1
|
||||
32
|
||||
25
|
||||
35
|
||||
8
|
||||
17
|
||||
7
|
||||
9
|
||||
4
|
||||
2
|
||||
34
|
||||
10
|
||||
3"#;
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&parse(&INPUT1)), 7 * 5);
|
||||
assert_eq!(solution1(&parse(&INPUT2)), 22 * 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(&parse(&INPUT1)), 8);
|
||||
assert_eq!(solution2(&parse(&INPUT2)), 19208);
|
||||
}
|
||||
}
|
||||
721
2020/src/day11.rs
Normal file
721
2020/src/day11.rs
Normal file
@@ -0,0 +1,721 @@
|
||||
//! --- Day 11: Seating System ---
|
||||
//! Your plane lands with plenty of time to spare. The final leg of your journey is a ferry that goes directly to the tropical island where you can finally start your vacation. As you reach the waiting area to board the ferry, you realize you're so early, nobody else has even arrived yet!
|
||||
//!
|
||||
//! By modeling the process people use to choose (or abandon) their seat in the waiting area, you're pretty sure you can predict the best place to sit. You make a quick map of the seat layout (your puzzle input).
|
||||
//!
|
||||
//! The seat layout fits neatly on a grid. Each position is either floor (.), an empty seat (L), or an occupied seat (#). For example, the initial seat layout might look like this:
|
||||
//!
|
||||
//! L.LL.LL.LL
|
||||
//! LLLLLLL.LL
|
||||
//! L.L.L..L..
|
||||
//! LLLL.LL.LL
|
||||
//! L.LL.LL.LL
|
||||
//! L.LLLLL.LL
|
||||
//! ..L.L.....
|
||||
//! LLLLLLLLLL
|
||||
//! L.LLLLLL.L
|
||||
//! L.LLLLL.LL
|
||||
//! Now, you just need to model the people who will be arriving shortly. Fortunately, people are entirely predictable and always follow a simple set of rules. All decisions are based on the number of occupied seats adjacent to a given seat (one of the eight positions immediately up, down, left, right, or diagonal from the seat). The following rules are applied to every seat simultaneously:
|
||||
//!
|
||||
//! If a seat is empty (L) and there are no occupied seats adjacent to it, the seat becomes occupied.
|
||||
//! If a seat is occupied (#) and four or more seats adjacent to it are also occupied, the seat becomes empty.
|
||||
//! Otherwise, the seat's state does not change.
|
||||
//! Floor (.) never changes; seats don't move, and nobody sits on the floor.
|
||||
//!
|
||||
//! After one round of these rules, every seat in the example layout becomes occupied:
|
||||
//!
|
||||
//! #.##.##.##
|
||||
//! #######.##
|
||||
//! #.#.#..#..
|
||||
//! ####.##.##
|
||||
//! #.##.##.##
|
||||
//! #.#####.##
|
||||
//! ..#.#.....
|
||||
//! ##########
|
||||
//! #.######.#
|
||||
//! #.#####.##
|
||||
//! After a second round, the seats with four or more occupied adjacent seats become empty again:
|
||||
//!
|
||||
//! #.LL.L#.##
|
||||
//! #LLLLLL.L#
|
||||
//! L.L.L..L..
|
||||
//! #LLL.LL.L#
|
||||
//! #.LL.LL.LL
|
||||
//! #.LLLL#.##
|
||||
//! ..L.L.....
|
||||
//! #LLLLLLLL#
|
||||
//! #.LLLLLL.L
|
||||
//! #.#LLLL.##
|
||||
//! This process continues for three more rounds:
|
||||
//!
|
||||
//! #.##.L#.##
|
||||
//! #L###LL.L#
|
||||
//! L.#.#..#..
|
||||
//! #L##.##.L#
|
||||
//! #.##.LL.LL
|
||||
//! #.###L#.##
|
||||
//! ..#.#.....
|
||||
//! #L######L#
|
||||
//! #.LL###L.L
|
||||
//! #.#L###.##
|
||||
//!
|
||||
//! #.#L.L#.##
|
||||
//! #LLL#LL.L#
|
||||
//! L.L.L..#..
|
||||
//! #LLL.##.L#
|
||||
//! #.LL.LL.LL
|
||||
//! #.LL#L#.##
|
||||
//! ..L.L.....
|
||||
//! #L#LLLL#L#
|
||||
//! #.LLLLLL.L
|
||||
//! #.#L#L#.##
|
||||
//!
|
||||
//! #.#L.L#.##
|
||||
//! #LLL#LL.L#
|
||||
//! L.#.L..#..
|
||||
//! #L##.##.L#
|
||||
//! #.#L.LL.LL
|
||||
//! #.#L#L#.##
|
||||
//! ..L.L.....
|
||||
//! #L#L##L#L#
|
||||
//! #.LLLLLL.L
|
||||
//! #.#L#L#.##
|
||||
//!
|
||||
//! At this point, something interesting happens: the chaos stabilizes and further applications of these rules cause no seats to change state! Once people stop moving around, you count 37 occupied seats.
|
||||
//!
|
||||
//! Simulate your seating area by applying the seating rules repeatedly until no seats change state. How many seats end up occupied?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! As soon as people start to arrive, you realize your mistake. People don't just care about adjacent seats - they care about the first seat they can see in each of those eight directions!
|
||||
//!
|
||||
//! Now, instead of considering just the eight immediately adjacent seats, consider the first seat in each of those eight directions. For example, the empty seat below would see eight occupied seats:
|
||||
//!
|
||||
//! .......#.
|
||||
//! ...#.....
|
||||
//! .#.......
|
||||
//! .........
|
||||
//! ..#L....#
|
||||
//! ....#....
|
||||
//! .........
|
||||
//! #........
|
||||
//! ...#.....
|
||||
//! The leftmost empty seat below would only see one empty seat, but cannot see any of the occupied ones:
|
||||
//!
|
||||
//! .............
|
||||
//! .L.L.#.#.#.#.
|
||||
//! .............
|
||||
//! The empty seat below would see no occupied seats:
|
||||
//!
|
||||
//! .##.##.
|
||||
//! #.#.#.#
|
||||
//! ##...##
|
||||
//! ...L...
|
||||
//! ##...##
|
||||
//! #.#.#.#
|
||||
//! .##.##.
|
||||
//! Also, people seem to be more tolerant than you expected: it now takes five or more visible occupied seats for an occupied seat to become empty (rather than four or more from the previous rules). The other rules still apply: empty seats that see no occupied seats become occupied, seats matching no rule don't change, and floor never changes.
|
||||
//!
|
||||
//! Given the same starting layout as above, these new rules cause the seating area to shift around as follows:
|
||||
//!
|
||||
//! L.LL.LL.LL
|
||||
//! LLLLLLL.LL
|
||||
//! L.L.L..L..
|
||||
//! LLLL.LL.LL
|
||||
//! L.LL.LL.LL
|
||||
//! L.LLLLL.LL
|
||||
//! ..L.L.....
|
||||
//! LLLLLLLLLL
|
||||
//! L.LLLLLL.L
|
||||
//! L.LLLLL.LL
|
||||
//! #.##.##.##
|
||||
//! #######.##
|
||||
//! #.#.#..#..
|
||||
//! ####.##.##
|
||||
//! #.##.##.##
|
||||
//! #.#####.##
|
||||
//! ..#.#.....
|
||||
//! ##########
|
||||
//! #.######.#
|
||||
//! #.#####.##
|
||||
//! #.LL.LL.L#
|
||||
//! #LLLLLL.LL
|
||||
//! L.L.L..L..
|
||||
//! LLLL.LL.LL
|
||||
//! L.LL.LL.LL
|
||||
//! L.LLLLL.LL
|
||||
//! ..L.L.....
|
||||
//! LLLLLLLLL#
|
||||
//! #.LLLLLL.L
|
||||
//! #.LLLLL.L#
|
||||
//! #.L#.##.L#
|
||||
//! #L#####.LL
|
||||
//! L.#.#..#..
|
||||
//! ##L#.##.##
|
||||
//! #.##.#L.##
|
||||
//! #.#####.#L
|
||||
//! ..#.#.....
|
||||
//! LLL####LL#
|
||||
//! #.L#####.L
|
||||
//! #.L####.L#
|
||||
//! #.L#.L#.L#
|
||||
//! #LLLLLL.LL
|
||||
//! L.L.L..#..
|
||||
//! ##LL.LL.L#
|
||||
//! L.LL.LL.L#
|
||||
//! #.LLLLL.LL
|
||||
//! ..L.L.....
|
||||
//! LLLLLLLLL#
|
||||
//! #.LLLLL#.L
|
||||
//! #.L#LL#.L#
|
||||
//! #.L#.L#.L#
|
||||
//! #LLLLLL.LL
|
||||
//! L.L.L..#..
|
||||
//! ##L#.#L.L#
|
||||
//! L.L#.#L.L#
|
||||
//! #.L####.LL
|
||||
//! ..#.#.....
|
||||
//! LLL###LLL#
|
||||
//! #.LLLLL#.L
|
||||
//! #.L#LL#.L#
|
||||
//! #.L#.L#.L#
|
||||
//! #LLLLLL.LL
|
||||
//! L.L.L..#..
|
||||
//! ##L#.#L.L#
|
||||
//! L.L#.LL.L#
|
||||
//! #.LLLL#.LL
|
||||
//! ..#.L.....
|
||||
//! LLL###LLL#
|
||||
//! #.LLLLL#.L
|
||||
//! #.L#LL#.L#
|
||||
//! Again, at this point, people stop shifting around and the seating area reaches equilibrium. Once this occurs, you count 26 occupied seats.
|
||||
//!
|
||||
//! Given the new visibility method and the rule change for occupied seats becoming empty, once equilibrium is reached, how many seats end up occupied?
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
enum State {
|
||||
/// '.'
|
||||
Floor,
|
||||
/// 'L'
|
||||
Empty,
|
||||
/// '#'
|
||||
Occupied,
|
||||
}
|
||||
|
||||
use std::fmt;
|
||||
impl fmt::Debug for State {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for State {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
State::Floor => write!(f, "."),
|
||||
State::Empty => write!(f, "L"),
|
||||
State::Occupied => write!(f, "#"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for State {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<State, String> {
|
||||
match s {
|
||||
"." => Ok(State::Floor),
|
||||
"L" => Ok(State::Empty),
|
||||
"#" => Ok(State::Occupied),
|
||||
s => Err(format!("Unknown map character: '{}'", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<char> for State {
|
||||
type Error = String;
|
||||
fn try_from(c: char) -> Result<State, String> {
|
||||
match c {
|
||||
'.' => Ok(State::Floor),
|
||||
'#' => Ok(State::Occupied),
|
||||
'L' => Ok(State::Empty),
|
||||
c => Err(format!("Unknown map character: '{}'", c)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Map {
|
||||
cells: Vec<State>,
|
||||
width: usize,
|
||||
height: usize,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Map {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Map {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "\n")?;
|
||||
for row in self.cells.chunks(self.width) {
|
||||
for c in row {
|
||||
write!(f, "{}", c)?;
|
||||
}
|
||||
write!(f, "\n")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Map {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Map, String> {
|
||||
let mut cells = Vec::new();
|
||||
let rows: Vec<_> = s.split("\n").collect();
|
||||
for row in &rows {
|
||||
let c: Result<Vec<_>, _> = row.chars().map(|cell| State::try_from(cell)).collect();
|
||||
cells.extend(c?);
|
||||
}
|
||||
let height = rows.len();
|
||||
let width = cells.len() / height;
|
||||
Ok(Map {
|
||||
cells,
|
||||
height,
|
||||
width,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
impl Index<(usize, usize)> for Map {
|
||||
type Output = State;
|
||||
|
||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
||||
&self.cells[x + y * self.width]
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<(usize, usize)> for Map {
|
||||
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Self::Output {
|
||||
&mut self.cells[x + y * self.width]
|
||||
}
|
||||
}
|
||||
|
||||
impl Map {
|
||||
fn new(width: usize, height: usize) -> Map {
|
||||
Map {
|
||||
width,
|
||||
height,
|
||||
cells: vec![State::Empty; width * height],
|
||||
}
|
||||
}
|
||||
fn adjacent_count(&self, x: usize, y: usize) -> usize {
|
||||
use std::cmp::min;
|
||||
let x_min = x.saturating_sub(1);
|
||||
let y_min = y.saturating_sub(1);
|
||||
let x_max = min(x + 1, self.width - 1);
|
||||
let y_max = min(y + 1, self.height - 1);
|
||||
|
||||
let mut cnt = 0;
|
||||
for y_off in y_min..=y_max {
|
||||
for x_off in x_min..=x_max {
|
||||
// Skip the current cell
|
||||
if x == x_off && y == y_off {
|
||||
continue;
|
||||
}
|
||||
if self[(x_off, y_off)] == State::Occupied {
|
||||
cnt += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
cnt
|
||||
}
|
||||
|
||||
/// Counts number of occupied seats in 8 cardinal directions. Stops if it hits an empty seat.
|
||||
fn line_of_sight_count(&self, x: usize, y: usize) -> usize {
|
||||
let incs = vec![
|
||||
// Right
|
||||
(1, 0),
|
||||
// Left
|
||||
(-1, 0),
|
||||
// Up
|
||||
(0, -1),
|
||||
// Down
|
||||
(0, 1),
|
||||
// Up-right
|
||||
(1, -1),
|
||||
// Up-left
|
||||
(-1, -1),
|
||||
// Down-right
|
||||
(1, 1),
|
||||
// Down-left
|
||||
(-1, 1),
|
||||
];
|
||||
|
||||
incs.into_iter()
|
||||
.map(|inc| self.shoot(x, y, inc))
|
||||
.filter(|&v| v)
|
||||
.count()
|
||||
}
|
||||
|
||||
/// Iterates over the map using the offsets until it hits an occupied seat or edge.
|
||||
/// If an occupied seat is found before an unoccupied seat or edge, true is returned.
|
||||
/// If an unoccupied seat is found before an occupied seat or edge, false is returned.
|
||||
/// If an edge is hit, false is returned.
|
||||
/// Floors are ignored.
|
||||
fn shoot(&self, x: usize, y: usize, (x_off, y_off): (isize, isize)) -> bool {
|
||||
let mut x = x as isize;
|
||||
let mut y = y as isize;
|
||||
let width = self.width as isize;
|
||||
let height = self.height as isize;
|
||||
loop {
|
||||
x = x + x_off;
|
||||
y = y + y_off;
|
||||
|
||||
// Hit an edge.
|
||||
if x < 0 || y < 0 || x >= width || y >= height {
|
||||
return false;
|
||||
}
|
||||
|
||||
let s = self[(x as usize, y as usize)];
|
||||
if let State::Empty = s {
|
||||
return false;
|
||||
}
|
||||
if let State::Occupied = s {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn occupied_count(&self) -> usize {
|
||||
self.cells.iter().filter(|&c| c == &State::Occupied).count()
|
||||
}
|
||||
}
|
||||
|
||||
fn step_solution1(map: &Map) -> Map {
|
||||
let mut new_m = Map::new(map.width, map.height);
|
||||
for y in 0..map.height {
|
||||
for x in 0..map.width {
|
||||
// Floor's never change
|
||||
if map[(x, y)] == State::Floor {
|
||||
new_m[(x, y)] = State::Floor;
|
||||
continue;
|
||||
}
|
||||
let new_cell = match map.adjacent_count(x, y) {
|
||||
0 => State::Occupied,
|
||||
c if c >= 4 => State::Empty,
|
||||
_ => map[(x, y)],
|
||||
};
|
||||
new_m[(x, y)] = new_cell;
|
||||
}
|
||||
}
|
||||
new_m
|
||||
}
|
||||
|
||||
fn step_solution2(map: &Map) -> Map {
|
||||
let mut new_m = Map::new(map.width, map.height);
|
||||
for y in 0..map.height {
|
||||
for x in 0..map.width {
|
||||
// Floor's never change
|
||||
if map[(x, y)] == State::Floor {
|
||||
new_m[(x, y)] = State::Floor;
|
||||
continue;
|
||||
}
|
||||
let new_cell = match map.line_of_sight_count(x, y) {
|
||||
0 => State::Occupied,
|
||||
c if c >= 5 => State::Empty,
|
||||
_ => map[(x, y)],
|
||||
};
|
||||
new_m[(x, y)] = new_cell;
|
||||
}
|
||||
}
|
||||
new_m
|
||||
}
|
||||
|
||||
#[aoc_generator(day11)]
|
||||
fn parse(input: &str) -> Map {
|
||||
input.parse().expect("Failed to parse map")
|
||||
}
|
||||
|
||||
#[aoc(day11, part1)]
|
||||
fn solution1(map: &Map) -> usize {
|
||||
let mut prev = step_solution1(map);
|
||||
let mut cur = step_solution1(&prev);
|
||||
while prev != cur {
|
||||
// Show map animating.
|
||||
// println!("{}", cur);
|
||||
prev = cur;
|
||||
cur = step_solution1(&prev);
|
||||
}
|
||||
cur.occupied_count()
|
||||
}
|
||||
|
||||
#[aoc(day11, part2)]
|
||||
fn solution2(map: &Map) -> usize {
|
||||
let mut prev = step_solution2(map);
|
||||
let mut cur = step_solution2(&prev);
|
||||
while prev != cur {
|
||||
// Show map animating.
|
||||
// println!("{}", cur);
|
||||
prev = cur;
|
||||
cur = step_solution2(&prev);
|
||||
}
|
||||
cur.occupied_count()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn index() {
|
||||
let m: Map = "#.L\n.#L\n.L#".parse().expect("Failed to parse map");
|
||||
assert_eq!(m[(1, 0)], State::Floor);
|
||||
assert_eq!(m[(0, 1)], State::Floor);
|
||||
assert_eq!(m[(0, 2)], State::Floor);
|
||||
|
||||
assert_eq!(m[(2, 0)], State::Empty);
|
||||
assert_eq!(m[(2, 1)], State::Empty);
|
||||
assert_eq!(m[(1, 2)], State::Empty);
|
||||
|
||||
assert_eq!(m[(0, 0)], State::Occupied);
|
||||
assert_eq!(m[(1, 1)], State::Occupied);
|
||||
assert_eq!(m[(2, 2)], State::Occupied);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn solution1() {
|
||||
let input = r#"L.LL.LL.LL
|
||||
LLLLLLL.LL
|
||||
L.L.L..L..
|
||||
LLLL.LL.LL
|
||||
L.LL.LL.LL
|
||||
L.LLLLL.LL
|
||||
..L.L.....
|
||||
LLLLLLLLLL
|
||||
L.LLLLLL.L
|
||||
L.LLLLL.LL"#
|
||||
.replace(' ', "");
|
||||
let steps: Vec<_> = vec![
|
||||
r#"#.##.##.##
|
||||
#######.##
|
||||
#.#.#..#..
|
||||
####.##.##
|
||||
#.##.##.##
|
||||
#.#####.##
|
||||
..#.#.....
|
||||
##########
|
||||
#.######.#
|
||||
#.#####.##"#,
|
||||
r#"#.LL.L#.##
|
||||
#LLLLLL.L#
|
||||
L.L.L..L..
|
||||
#LLL.LL.L#
|
||||
#.LL.LL.LL
|
||||
#.LLLL#.##
|
||||
..L.L.....
|
||||
#LLLLLLLL#
|
||||
#.LLLLLL.L
|
||||
#.#LLLL.##"#,
|
||||
r#"#.##.L#.##
|
||||
#L###LL.L#
|
||||
L.#.#..#..
|
||||
#L##.##.L#
|
||||
#.##.LL.LL
|
||||
#.###L#.##
|
||||
..#.#.....
|
||||
#L######L#
|
||||
#.LL###L.L
|
||||
#.#L###.##"#,
|
||||
r#"#.#L.L#.##
|
||||
#LLL#LL.L#
|
||||
L.L.L..#..
|
||||
#LLL.##.L#
|
||||
#.LL.LL.LL
|
||||
#.LL#L#.##
|
||||
..L.L.....
|
||||
#L#LLLL#L#
|
||||
#.LLLLLL.L
|
||||
#.#L#L#.##"#,
|
||||
r#"#.#L.L#.##
|
||||
#LLL#LL.L#
|
||||
L.#.L..#..
|
||||
#L##.##.L#
|
||||
#.#L.LL.LL
|
||||
#.#L#L#.##
|
||||
..L.L.....
|
||||
#L#L##L#L#
|
||||
#.LLLLLL.L
|
||||
#.#L#L#.##"#,
|
||||
]
|
||||
.iter()
|
||||
// Trim whitespace that rustfmt keeps introducing.
|
||||
.map(|m| m.replace(' ', ""))
|
||||
.collect();
|
||||
|
||||
let mut m = input.parse().expect("Failed to parse map");
|
||||
for (i, want_input) in steps.iter().enumerate() {
|
||||
let want: Map = want_input
|
||||
.parse()
|
||||
.expect(&format!("Failed to parse step {}", i));
|
||||
let got = step_solution1(&m);
|
||||
assert_eq!(want, got, "step {}\nm {}", i, m);
|
||||
m = got;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn line_of_sight_count() {
|
||||
let test_input = vec![
|
||||
(
|
||||
8,
|
||||
(3, 4),
|
||||
r#".......#.
|
||||
...#.....
|
||||
.#.......
|
||||
.........
|
||||
..#L....#
|
||||
....#....
|
||||
.........
|
||||
#........
|
||||
...#....."#
|
||||
.replace(' ', ""),
|
||||
),
|
||||
(
|
||||
4,
|
||||
(3, 0),
|
||||
r#"#.L#.##.L#
|
||||
#L#####.LL
|
||||
L.#.#..#..
|
||||
##L#.##.##
|
||||
#.##.#L.##
|
||||
#.#####.#L
|
||||
..#.#.....
|
||||
LLL####LL#
|
||||
#.L#####.L
|
||||
#.L####.L#"#
|
||||
.replace(' ', ""),
|
||||
),
|
||||
(
|
||||
0,
|
||||
(1, 1),
|
||||
r#".............
|
||||
.L.L.#.#.#.#.
|
||||
............."#
|
||||
.replace(' ', ""),
|
||||
),
|
||||
(
|
||||
0,
|
||||
(3, 3),
|
||||
r#".##.##.
|
||||
#.#.#.#
|
||||
##...##
|
||||
...L...
|
||||
##...##
|
||||
#.#.#.#
|
||||
.##.##."#
|
||||
.replace(' ', ""),
|
||||
),
|
||||
];
|
||||
for (want, (x, y), input) in test_input {
|
||||
let m: Map = input.parse().expect("Failed to parse map data");
|
||||
assert_eq!(want, m.line_of_sight_count(x, y), "map {}", m);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn solution2() {
|
||||
let input = r#"L.LL.LL.LL
|
||||
LLLLLLL.LL
|
||||
L.L.L..L..
|
||||
LLLL.LL.LL
|
||||
L.LL.LL.LL
|
||||
L.LLLLL.LL
|
||||
..L.L.....
|
||||
LLLLLLLLLL
|
||||
L.LLLLLL.L
|
||||
L.LLLLL.LL"#
|
||||
.replace(' ', "");
|
||||
let steps: Vec<_> = vec![
|
||||
r#"#.##.##.##
|
||||
#######.##
|
||||
#.#.#..#..
|
||||
####.##.##
|
||||
#.##.##.##
|
||||
#.#####.##
|
||||
..#.#.....
|
||||
##########
|
||||
#.######.#
|
||||
#.#####.##"#,
|
||||
r#"#.LL.LL.L#
|
||||
#LLLLLL.LL
|
||||
L.L.L..L..
|
||||
LLLL.LL.LL
|
||||
L.LL.LL.LL
|
||||
L.LLLLL.LL
|
||||
..L.L.....
|
||||
LLLLLLLLL#
|
||||
#.LLLLLL.L
|
||||
#.LLLLL.L#"#,
|
||||
r#"#.L#.##.L#
|
||||
#L#####.LL
|
||||
L.#.#..#..
|
||||
##L#.##.##
|
||||
#.##.#L.##
|
||||
#.#####.#L
|
||||
..#.#.....
|
||||
LLL####LL#
|
||||
#.L#####.L
|
||||
#.L####.L#"#,
|
||||
r#"#.L#.L#.L#
|
||||
#LLLLLL.LL
|
||||
L.L.L..#..
|
||||
##LL.LL.L#
|
||||
L.LL.LL.L#
|
||||
#.LLLLL.LL
|
||||
..L.L.....
|
||||
LLLLLLLLL#
|
||||
#.LLLLL#.L
|
||||
#.L#LL#.L#"#,
|
||||
r#"#.L#.L#.L#
|
||||
#LLLLLL.LL
|
||||
L.L.L..#..
|
||||
##L#.#L.L#
|
||||
L.L#.#L.L#
|
||||
#.L####.LL
|
||||
..#.#.....
|
||||
LLL###LLL#
|
||||
#.LLLLL#.L
|
||||
#.L#LL#.L#"#,
|
||||
r#"#.L#.L#.L#
|
||||
#LLLLLL.LL
|
||||
L.L.L..#..
|
||||
##L#.#L.L#
|
||||
L.L#.LL.L#
|
||||
#.LLLL#.LL
|
||||
..#.L.....
|
||||
LLL###LLL#
|
||||
#.LLLLL#.L
|
||||
#.L#LL#.L#"#,
|
||||
]
|
||||
.iter()
|
||||
.map(|s| s.replace(' ', ""))
|
||||
.collect();
|
||||
let mut m = input.parse().expect("Failed to parse map");
|
||||
for (i, want_input) in steps.iter().enumerate() {
|
||||
let want: Map = want_input
|
||||
.parse()
|
||||
.expect(&format!("Failed to parse step {}", i));
|
||||
let got = step_solution2(&m);
|
||||
assert_eq!(want, got, "step {}\nm {}", i, m);
|
||||
m = got;
|
||||
}
|
||||
}
|
||||
}
|
||||
291
2020/src/day12.rs
Normal file
291
2020/src/day12.rs
Normal file
@@ -0,0 +1,291 @@
|
||||
//! --- Day 12: Rain Risk ---
|
||||
//! Your ferry made decent progress toward the island, but the storm came in faster than anyone expected. The ferry needs to take evasive actions!
|
||||
//!
|
||||
//! Unfortunately, the ship's navigation computer seems to be malfunctioning; rather than giving a route directly to safety, it produced extremely circuitous instructions. When the captain uses the PA system to ask if anyone can help, you quickly volunteer.
|
||||
//!
|
||||
//! The navigation instructions (your puzzle input) consists of a sequence of single-character actions paired with integer input values. After staring at them for a few minutes, you work out what they probably mean:
|
||||
//!
|
||||
//! Action N means to move north by the given value.
|
||||
//! Action S means to move south by the given value.
|
||||
//! Action E means to move east by the given value.
|
||||
//! Action W means to move west by the given value.
|
||||
//! Action L means to turn left the given number of degrees.
|
||||
//! Action R means to turn right the given number of degrees.
|
||||
//! Action F means to move forward by the given value in the direction the ship is currently facing.
|
||||
//! The ship starts by facing east. Only the L and R actions change the direction the ship is facing. (That is, if the ship is facing east and the next instruction is N10, the ship would move north 10 units, but would still move east if the following action were F.)
|
||||
//!
|
||||
//! For example:
|
||||
//!
|
||||
//! F10
|
||||
//! N3
|
||||
//! F7
|
||||
//! R90
|
||||
//! F11
|
||||
//! These instructions would be handled as follows:
|
||||
//!
|
||||
//! F10 would move the ship 10 units east (because the ship starts by facing east) to east 10, north 0.
|
||||
//! N3 would move the ship 3 units north to east 10, north 3.
|
||||
//! F7 would move the ship another 7 units east (because the ship is still facing east) to east 17, north 3.
|
||||
//! R90 would cause the ship to turn right by 90 degrees and face south; it remains at east 17, north 3.
|
||||
//! F11 would move the ship 11 units south to east 17, south 8.
|
||||
//! At the end of these instructions, the ship's Manhattan distance (sum of the absolute values of its east/west position and its north/south position) from its starting position is 17 + 8 = 25.
|
||||
//!
|
||||
//! Figure out where the navigation instructions lead. What is the Manhattan distance between that location and the ship's starting position?
|
||||
|
||||
//! --- Part Two ---
|
||||
//! Before you can give the destination to the captain, you realize that the actual action meanings were printed on the back of the instructions the whole time.
|
||||
//!
|
||||
//! Almost all of the actions indicate how to move a waypoint which is relative to the ship's position:
|
||||
//!
|
||||
//! Action N means to move the waypoint north by the given value.
|
||||
//! Action S means to move the waypoint south by the given value.
|
||||
//! Action E means to move the waypoint east by the given value.
|
||||
//! Action W means to move the waypoint west by the given value.
|
||||
//! Action L means to rotate the waypoint around the ship left (counter-clockwise) the given number of degrees.
|
||||
//! Action R means to rotate the waypoint around the ship right (clockwise) the given number of degrees.
|
||||
//! Action F means to move forward to the waypoint a number of times equal to the given value.
|
||||
//! The waypoint starts 10 units east and 1 unit north relative to the ship. The waypoint is relative to the ship; that is, if the ship moves, the waypoint moves with it.
|
||||
//!
|
||||
//! For example, using the same instructions as above:
|
||||
//!
|
||||
//! F10 moves the ship to the waypoint 10 times (a total of 100 units east and 10 units north), leaving the ship at east 100, north 10. The waypoint stays 10 units east and 1 unit north of the ship.
|
||||
//! N3 moves the waypoint 3 units north to 10 units east and 4 units north of the ship. The ship remains at east 100, north 10.
|
||||
//! F7 moves the ship to the waypoint 7 times (a total of 70 units east and 28 units north), leaving the ship at east 170, north 38. The waypoint stays 10 units east and 4 units north of the ship.
|
||||
//! R90 rotates the waypoint around the ship clockwise 90 degrees, moving it to 4 units east and 10 units south of the ship. The ship remains at east 170, north 38.
|
||||
//! F11 moves the ship to the waypoint 11 times (a total of 44 units east and 110 units south), leaving the ship at east 214, south 72. The waypoint stays 4 units east and 10 units south of the ship.
|
||||
//! After these operations, the ship's Manhattan distance from its starting position is 214 + 72 = 286.
|
||||
//!
|
||||
//! Figure out where the navigation instructions actually lead. What is the Manhattan distance between that location and the ship's starting position?
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum Action {
|
||||
North(u32),
|
||||
South(u32),
|
||||
East(u32),
|
||||
West(u32),
|
||||
|
||||
Right(u32),
|
||||
Left(u32),
|
||||
|
||||
Forward(u32),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum Orientation {
|
||||
North,
|
||||
South,
|
||||
East,
|
||||
West,
|
||||
}
|
||||
|
||||
impl From<i32> for Orientation {
|
||||
fn from(i: i32) -> Orientation {
|
||||
assert_eq!(i % 90, 0);
|
||||
match ((i + 360) % 360) / 90 {
|
||||
0 => Orientation::North,
|
||||
1 => Orientation::East,
|
||||
2 => Orientation::South,
|
||||
3 => Orientation::West,
|
||||
c => panic!(format!("Should never see orientation of {}", c)),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Into<i32> for Orientation {
|
||||
fn into(self) -> i32 {
|
||||
match self {
|
||||
Orientation::North => 0,
|
||||
Orientation::East => 90,
|
||||
Orientation::South => 180,
|
||||
Orientation::West => 270,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
impl FromStr for Action {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Action, String> {
|
||||
let c = s
|
||||
.chars()
|
||||
.nth(0)
|
||||
.ok_or("Couldn't get first char".to_string())?;
|
||||
let v = s[1..]
|
||||
.parse::<u32>()
|
||||
.map_err(|e| format!("{}: '{}'", e, s))?;
|
||||
use Action::*;
|
||||
Ok(match c {
|
||||
'N' => North(v),
|
||||
'S' => South(v),
|
||||
'E' => East(v),
|
||||
'W' => West(v),
|
||||
|
||||
'R' => Right(v),
|
||||
'L' => Left(v),
|
||||
|
||||
'F' => Forward(v),
|
||||
c => return Err(format!("Unexpected action character '{}'", c)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day12)]
|
||||
fn parse(input: &str) -> Vec<Action> {
|
||||
input
|
||||
.split('\n')
|
||||
.map(|l| l.parse().expect("Failed to parse action"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
struct Waypoint {
|
||||
// East is +, West is -.
|
||||
x: i32,
|
||||
// North is +, South is -.
|
||||
y: i32,
|
||||
}
|
||||
|
||||
struct Ship {
|
||||
orientation: Orientation,
|
||||
// East is +, West is -.
|
||||
x: i32,
|
||||
// North is +, South is -.
|
||||
y: i32,
|
||||
waypoint: Option<Waypoint>,
|
||||
}
|
||||
|
||||
impl Default for Ship {
|
||||
fn default() -> Self {
|
||||
Ship {
|
||||
orientation: Orientation::East,
|
||||
x: 0,
|
||||
y: 0,
|
||||
waypoint: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ship {
|
||||
fn new(waypoint_x_offset: i32, waypoint_y_offset: i32) -> Ship {
|
||||
Ship {
|
||||
waypoint: Some(Waypoint {
|
||||
x: waypoint_x_offset,
|
||||
y: waypoint_y_offset,
|
||||
}),
|
||||
..Ship::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn act_part1(&mut self, action: &Action) {
|
||||
match action {
|
||||
Action::North(v) => self.y += *v as i32,
|
||||
Action::South(v) => self.y -= *v as i32,
|
||||
Action::East(v) => self.x += *v as i32,
|
||||
Action::West(v) => self.x -= *v as i32,
|
||||
|
||||
Action::Right(v) => {
|
||||
self.orientation = {
|
||||
let i: i32 = self.orientation.into();
|
||||
(i + *v as i32).into()
|
||||
}
|
||||
}
|
||||
Action::Left(v) => {
|
||||
self.orientation = {
|
||||
let i: i32 = self.orientation.into();
|
||||
(i - *v as i32).into()
|
||||
}
|
||||
}
|
||||
Action::Forward(v) => match self.orientation {
|
||||
Orientation::North => self.y += *v as i32,
|
||||
Orientation::South => self.y -= *v as i32,
|
||||
Orientation::East => self.x += *v as i32,
|
||||
Orientation::West => self.x -= *v as i32,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
fn act_part2(&mut self, action: &Action) {
|
||||
let mut wp = self.waypoint.take().unwrap();
|
||||
match action {
|
||||
Action::North(v) => wp.y += *v as i32,
|
||||
Action::South(v) => wp.y -= *v as i32,
|
||||
Action::East(v) => wp.x += *v as i32,
|
||||
Action::West(v) => wp.x -= *v as i32,
|
||||
|
||||
Action::Right(v) => {
|
||||
assert_eq!(v % 90, 0);
|
||||
for _ in 0..(v / 90) {
|
||||
std::mem::swap(&mut wp.x, &mut wp.y);
|
||||
wp.y *= -1;
|
||||
}
|
||||
}
|
||||
Action::Left(v) => {
|
||||
assert_eq!(v % 90, 0);
|
||||
for _ in 0..(v / 90) {
|
||||
std::mem::swap(&mut wp.x, &mut wp.y);
|
||||
wp.x *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
Action::Forward(v) => {
|
||||
self.x += wp.x * *v as i32;
|
||||
self.y += wp.y * *v as i32;
|
||||
}
|
||||
};
|
||||
self.waypoint = Some(wp);
|
||||
}
|
||||
|
||||
fn act(&mut self, action: &Action) {
|
||||
match self.waypoint {
|
||||
None => self.act_part1(action),
|
||||
Some(_) => self.act_part2(action),
|
||||
};
|
||||
}
|
||||
|
||||
fn manhattan_distance(&self) -> u32 {
|
||||
(self.x.abs() + self.y.abs()) as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc(day12, part1)]
|
||||
fn solution1(actions: &[Action]) -> u32 {
|
||||
let mut s = Ship::default();
|
||||
actions.iter().for_each(|a| s.act(a));
|
||||
s.manhattan_distance()
|
||||
}
|
||||
|
||||
#[aoc(day12, part2)]
|
||||
fn solution2(actions: &[Action]) -> u32 {
|
||||
let mut s = Ship::new(10, 1);
|
||||
actions.iter().for_each(|a| s.act(a));
|
||||
s.manhattan_distance()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const INPUT: &'static str = r#"F10
|
||||
N3
|
||||
F7
|
||||
R90
|
||||
F11"#;
|
||||
|
||||
#[test]
|
||||
fn parser() {
|
||||
use Action::*;
|
||||
assert_eq!(
|
||||
parse(INPUT),
|
||||
vec![Forward(10), North(3), Forward(7), Right(90), Forward(11),]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&parse(INPUT)), 17 + 8);
|
||||
}
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(&parse(INPUT)), 214 + 72);
|
||||
}
|
||||
}
|
||||
275
2020/src/day13.rs
Normal file
275
2020/src/day13.rs
Normal file
@@ -0,0 +1,275 @@
|
||||
//! --- Day 13: Shuttle Search ---
|
||||
//! Your ferry can make it safely to a nearby port, but it won't get much further. When you call to book another ship, you discover that no ships embark from that port to your vacation island. You'll need to get from the port to the nearest airport.
|
||||
//!
|
||||
//! Fortunately, a shuttle bus service is available to bring you from the sea port to the airport! Each bus has an ID number that also indicates how often the bus leaves for the airport.
|
||||
//!
|
||||
//! Bus schedules are defined based on a timestamp that measures the number of minutes since some fixed reference point in the past. At timestamp 0, every bus simultaneously departed from the sea port. After that, each bus travels to the airport, then various other locations, and finally returns to the sea port to repeat its journey forever.
|
||||
//!
|
||||
//! The time this loop takes a particular bus is also its ID number: the bus with ID 5 departs from the sea port at timestamps 0, 5, 10, 15, and so on. The bus with ID 11 departs at 0, 11, 22, 33, and so on. If you are there when the bus departs, you can ride that bus to the airport!
|
||||
//!
|
||||
//! Your notes (your puzzle input) consist of two lines. The first line is your estimate of the earliest timestamp you could depart on a bus. The second line lists the bus IDs that are in service according to the shuttle company; entries that show x must be out of service, so you decide to ignore them.
|
||||
//!
|
||||
//! To save time once you arrive, your goal is to figure out the earliest bus you can take to the airport. (There will be exactly one such bus.)
|
||||
//!
|
||||
//! For example, suppose you have the following notes:
|
||||
//!
|
||||
//! 939
|
||||
//! 7,13,x,x,59,x,31,19
|
||||
//! Here, the earliest timestamp you could depart is 939, and the bus IDs in service are 7, 13, 59, 31, and 19. Near timestamp 939, these bus IDs depart at the times marked D:
|
||||
//!
|
||||
//! time bus 7 bus 13 bus 59 bus 31 bus 19
|
||||
//! 929 . . . . .
|
||||
//! 930 . . . D .
|
||||
//! 931 D . . . D
|
||||
//! 932 . . . . .
|
||||
//! 933 . . . . .
|
||||
//! 934 . . . . .
|
||||
//! 935 . . . . .
|
||||
//! 936 . D . . .
|
||||
//! 937 . . . . .
|
||||
//! 938 D . . . .
|
||||
//! 939 . . . . .
|
||||
//! 940 . . . . .
|
||||
//! 941 . . . . .
|
||||
//! 942 . . . . .
|
||||
//! 943 . . . . .
|
||||
//! 944 . . D . .
|
||||
//! 945 D . . . .
|
||||
//! 946 . . . . .
|
||||
//! 947 . . . . .
|
||||
//! 948 . . . . .
|
||||
//! 949 . D . . .
|
||||
//! The earliest bus you could take is bus ID 59. It doesn't depart until timestamp 944, so you would need to wait 944 - 939 = 5 minutes before it departs. Multiplying the bus ID by the number of minutes you'd need to wait gives 295.
|
||||
//!
|
||||
//! What is the ID of the earliest bus you can take to the airport multiplied by the number of minutes you'll need to wait for that bus?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! The shuttle company is running a contest: one gold coin for anyone that can find the earliest timestamp such that the first bus ID departs at that time and each subsequent listed bus ID departs at that subsequent minute. (The first line in your input is no longer relevant.)
|
||||
//!
|
||||
//! For example, suppose you have the same list of bus IDs as above:
|
||||
//!
|
||||
//! 7,13,x,x,59,x,31,19
|
||||
//! An x in the schedule means there are no constraints on what bus IDs must depart at that time.
|
||||
//!
|
||||
//! This means you are looking for the earliest timestamp (called t) such that:
|
||||
//!
|
||||
//! Bus ID 7 departs at timestamp t.
|
||||
//! Bus ID 13 departs one minute after timestamp t.
|
||||
//! There are no requirements or restrictions on departures at two or three minutes after timestamp t.
|
||||
//! Bus ID 59 departs four minutes after timestamp t.
|
||||
//! There are no requirements or restrictions on departures at five minutes after timestamp t.
|
||||
//! Bus ID 31 departs six minutes after timestamp t.
|
||||
//! Bus ID 19 departs seven minutes after timestamp t.
|
||||
//! The only bus departures that matter are the listed bus IDs at their specific offsets from t. Those bus IDs can depart at other times, and other bus IDs can depart at those times. For example, in the list above, because bus ID 19 must depart seven minutes after the timestamp at which bus ID 7 departs, bus ID 7 will always also be departing with bus ID 19 at seven minutes after timestamp t.
|
||||
//!
|
||||
//! In this example, the earliest timestamp at which this occurs is 1068781:
|
||||
//!
|
||||
//! time bus 7 bus 13 bus 59 bus 31 bus 19
|
||||
//! 1068773 . . . . .
|
||||
//! 1068774 D . . . .
|
||||
//! 1068775 . . . . .
|
||||
//! 1068776 . . . . .
|
||||
//! 1068777 . . . . .
|
||||
//! 1068778 . . . . .
|
||||
//! 1068779 . . . . .
|
||||
//! 1068780 . . . . .
|
||||
//! 1068781 D . . . .
|
||||
//! 1068782 . D . . .
|
||||
//! 1068783 . . . . .
|
||||
//! 1068784 . . . . .
|
||||
//! 1068785 . . D . .
|
||||
//! 1068786 . . . . .
|
||||
//! 1068787 . . . D .
|
||||
//! 1068788 D . . . D
|
||||
//! 1068789 . . . . .
|
||||
//! 1068790 . . . . .
|
||||
//! 1068791 . . . . .
|
||||
//! 1068792 . . . . .
|
||||
//! 1068793 . . . . .
|
||||
//! 1068794 . . . . .
|
||||
//! 1068795 D D . . .
|
||||
//! 1068796 . . . . .
|
||||
//! 1068797 . . . . .
|
||||
//! In the above example, bus ID 7 departs at timestamp 1068788 (seven minutes after t). This is fine; the only requirement on that minute is that bus ID 19 departs then, and it does.
|
||||
//!
|
||||
//! Here are some other examples:
|
||||
//!
|
||||
//! The earliest timestamp that matches the list 17,x,13,19 is 3417.
|
||||
//! 67,7,59,61 first occurs at timestamp 754018.
|
||||
//! 67,x,7,59,61 first occurs at timestamp 779210.
|
||||
//! 67,7,x,59,61 first occurs at timestamp 1261476.
|
||||
//! 1789,37,47,1889 first occurs at timestamp 1202161486.
|
||||
//! However, with so many bus IDs in your list, surely the actual earliest timestamp will be larger than 100000000000000!
|
||||
//!
|
||||
//! What is the earliest timestamp such that all of the listed bus IDs depart at offsets matching their positions in the list?
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
struct Schedule {
|
||||
time: u32,
|
||||
buses: Vec<u32>,
|
||||
}
|
||||
|
||||
#[aoc_generator(day13, part1)]
|
||||
fn parse1(input: &str) -> Schedule {
|
||||
let mut it = input.split('\n');
|
||||
let time = it
|
||||
.next()
|
||||
.expect("Premature EOF")
|
||||
.parse()
|
||||
.expect("Can't parse time");
|
||||
let buses = it
|
||||
.next()
|
||||
.expect("Premature EOF")
|
||||
.split(',')
|
||||
.filter_map(|s| s.parse::<u32>().ok())
|
||||
.collect();
|
||||
Schedule { time, buses }
|
||||
}
|
||||
|
||||
#[aoc(day13, part1)]
|
||||
fn solution1(sch: &Schedule) -> u32 {
|
||||
let (bus, next) = sch
|
||||
.buses
|
||||
.iter()
|
||||
// Find the next bus time after sch.time.
|
||||
.map(|b| (b, b * ((sch.time / b) + 1)))
|
||||
// Find the earliest next bus time.
|
||||
.min_by(|i1, i2| i1.1.cmp(&i2.1))
|
||||
.unwrap();
|
||||
bus * (next - sch.time)
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct Departure {
|
||||
bus: usize,
|
||||
delay: usize,
|
||||
}
|
||||
|
||||
#[aoc_generator(day13, part2)]
|
||||
fn parse2(input: &str) -> Vec<Departure> {
|
||||
let mut it = input.split('\n');
|
||||
let _ = it.next().expect("Premature EOF");
|
||||
it.next()
|
||||
.expect("Premature EOF")
|
||||
.split(',')
|
||||
.enumerate()
|
||||
.filter_map(|(i, s)| Some((i, s.parse::<usize>().ok()?)))
|
||||
.map(|(delay, bus)| Departure { bus, delay })
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn inv_mod(a: usize, m: usize) -> usize {
|
||||
{
|
||||
let a = a % m;
|
||||
for i in 1..m {
|
||||
if (a * i) % m == 1 {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
panic!(format!("no inverse modulo found for {}^-1 % {}", a, m));
|
||||
}
|
||||
|
||||
/// Based on http://homepages.math.uic.edu/~leon/mcs425-s08/handouts/chinese_remainder.pdf
|
||||
/// a_m is a Vec with (a, m) as used in the above PDF. m are pairwise relatively prime positive
|
||||
/// integers and a are any integers.
|
||||
fn chinese_remainder(a_m: Vec<(usize, usize)>) -> usize {
|
||||
let a: Vec<_> = a_m.iter().map(|(a, _m)| a).collect();
|
||||
let m: Vec<_> = a_m.iter().map(|(_a, m)| m).collect();
|
||||
let m_all = m.iter().fold(1, |acc, m| *m * acc);
|
||||
let z: Vec<_> = m.iter().map(|m| m_all / *m).collect();
|
||||
let y: Vec<_> = m
|
||||
.iter()
|
||||
.zip(z.iter())
|
||||
.map(|(m, z)| inv_mod(*z, **m))
|
||||
.collect();
|
||||
let w: Vec<_> = y
|
||||
.iter()
|
||||
.zip(z.iter())
|
||||
.map(|(y, z)| (*y * *z) % m_all)
|
||||
.collect();
|
||||
|
||||
let x = a
|
||||
.iter()
|
||||
.zip(w.iter())
|
||||
.fold(0, |acc, (a, w)| acc + (*a * *w));
|
||||
x % m_all
|
||||
}
|
||||
|
||||
#[aoc(day13, part2)]
|
||||
fn solution2(sch: &[Departure]) -> usize {
|
||||
let a_m: Vec<(_, _)> = sch.iter().map(|d| (d.bus - d.delay, d.bus)).collect();
|
||||
chinese_remainder(a_m)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &'static str = r#"939
|
||||
7,13,x,x,59,x,31,19"#;
|
||||
|
||||
#[test]
|
||||
fn parsing1() {
|
||||
assert_eq!(
|
||||
parse1(INPUT),
|
||||
Schedule {
|
||||
time: 939,
|
||||
buses: vec![7, 13, 59, 31, 19],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&parse1(INPUT)), 295);
|
||||
}
|
||||
#[test]
|
||||
fn part2() {
|
||||
for (input, want) in vec![
|
||||
("17,x,13,19", 3417),
|
||||
("67,7,59,61", 754018),
|
||||
("67,x,7,59,61", 779210),
|
||||
("7,13,x,x,59,x,31,19", 1068781),
|
||||
("67,7,x,59,61", 1261476),
|
||||
("1789,37,47,1889", 1202161486),
|
||||
] {
|
||||
// Insert fake header '123\n' to make the parse2 function happy.
|
||||
assert_eq!(solution2(&parse2(&format!("123\n{}", input))), want);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inverse_modulo() {
|
||||
assert_eq!(inv_mod(8400, 11), 8);
|
||||
assert_eq!(inv_mod(7, 11), 8);
|
||||
assert_eq!(inv_mod(5775, 16), 15);
|
||||
assert_eq!(inv_mod(15, 16), 15);
|
||||
assert_eq!(inv_mod(4400, 21), 2);
|
||||
assert_eq!(inv_mod(11, 21), 2);
|
||||
assert_eq!(inv_mod(3696, 25), 6);
|
||||
assert_eq!(inv_mod(21, 25), 6);
|
||||
assert_eq!(inv_mod(243257, 11), 4);
|
||||
assert_eq!(inv_mod(3, 11), 4);
|
||||
assert_eq!(inv_mod(243257, 13), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chinese_remainder_theorem() {
|
||||
assert_eq!(chinese_remainder(vec![(2, 5), (3, 7)]), 17);
|
||||
assert_eq!(chinese_remainder(vec![(1, 3), (4, 5), (6, 7)]), 34);
|
||||
assert_eq!(chinese_remainder(vec![(3, 5), (2, 6), (4, 7)]), 158);
|
||||
assert_eq!(
|
||||
chinese_remainder(vec![(1, 5), (2, 7), (3, 9), (4, 11)]),
|
||||
1731
|
||||
);
|
||||
// http://homepages.math.uic.edu/~leon/mcs425-s08/handouts/chinese_remainder.pdf
|
||||
// says this answer is 51669 which doesn't check out.
|
||||
assert_eq!(
|
||||
chinese_remainder(vec![(6, 11), (13, 16), (9, 21), (19, 25),]),
|
||||
89469
|
||||
);
|
||||
}
|
||||
}
|
||||
243
2020/src/day14.rs
Normal file
243
2020/src/day14.rs
Normal file
@@ -0,0 +1,243 @@
|
||||
//! --- Day 14: Docking Data ---
|
||||
//! As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialized in the docking program's memory.
|
||||
//!
|
||||
//! After a brief inspection, you discover that the sea port's computer system uses a strange bitmask system in its initialization program. Although you don't have the correct decoder chip handy, you can emulate it in software!
|
||||
//!
|
||||
//! The initialization program (your puzzle input) can either update the bitmask or write a value to memory. Values and memory addresses are both 36-bit unsigned integers. For example, ignoring bitmasks for a moment, a line like mem[8] = 11 would write the value 11 to memory address 8.
|
||||
//!
|
||||
//! The bitmask is always given as a string of 36 bits, written with the most significant bit (representing 2^35) on the left and the least significant bit (2^0, that is, the 1s bit) on the right. The current bitmask is applied to values immediately before they are written to memory: a 0 or 1 overwrites the corresponding bit in the value, while an X leaves the bit in the value unchanged.
|
||||
//!
|
||||
//! For example, consider the following program:
|
||||
//!
|
||||
//! mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
|
||||
//! mem[8] = 11
|
||||
//! mem[7] = 101
|
||||
//! mem[8] = 0
|
||||
//! This program starts by specifying a bitmask (mask = ....). The mask it specifies will overwrite two bits in every written value: the 2s bit is overwritten with 0, and the 64s bit is overwritten with 1.
|
||||
//!
|
||||
//! The program then attempts to write the value 11 to memory address 8. By expanding everything out to individual bits, the mask is applied as follows:
|
||||
//!
|
||||
//! value: 000000000000000000000000000000001011 (decimal 11)
|
||||
//! mask: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
|
||||
//! result: 000000000000000000000000000001001001 (decimal 73)
|
||||
//! So, because of the mask, the value 73 is written to memory address 8 instead. Then, the program tries to write 101 to address 7:
|
||||
//!
|
||||
//! value: 000000000000000000000000000001100101 (decimal 101)
|
||||
//! mask: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
|
||||
//! result: 000000000000000000000000000001100101 (decimal 101)
|
||||
//! This time, the mask has no effect, as the bits it overwrote were already the values the mask tried to set. Finally, the program tries to write 0 to address 8:
|
||||
//!
|
||||
//! value: 000000000000000000000000000000000000 (decimal 0)
|
||||
//! mask: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
|
||||
//! result: 000000000000000000000000000001000000 (decimal 64)
|
||||
//! 64 is written to address 8 instead, overwriting the value that was there previously.
|
||||
//!
|
||||
//! To initialize your ferry's docking program, you need the sum of all values left in memory after the initialization program completes. (The entire 36-bit address space begins initialized to the value 0 at every address.) In the above example, only two values in memory are not zero - 101 (at address 7) and 64 (at address 8) - producing a sum of 165.
|
||||
//!
|
||||
//! Execute the initialization program. What is the sum of all values left in memory after it completes?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! For some reason, the sea port's computer system still can't communicate with your ferry's docking program. It must be using version 2 of the decoder chip!
|
||||
//!
|
||||
//! A version 2 decoder chip doesn't modify the values being written at all. Instead, it acts as a memory address decoder. Immediately before a value is written to memory, each bit in the bitmask modifies the corresponding bit of the destination memory address in the following way:
|
||||
//!
|
||||
//! If the bitmask bit is 0, the corresponding memory address bit is unchanged.
|
||||
//! If the bitmask bit is 1, the corresponding memory address bit is overwritten with 1.
|
||||
//! If the bitmask bit is X, the corresponding memory address bit is floating.
|
||||
//! A floating bit is not connected to anything and instead fluctuates unpredictably. In practice, this means the floating bits will take on all possible values, potentially causing many memory addresses to be written all at once!
|
||||
//!
|
||||
//! For example, consider the following program:
|
||||
//!
|
||||
//! mask = 000000000000000000000000000000X1001X
|
||||
//! mem[42] = 100
|
||||
//! mask = 00000000000000000000000000000000X0XX
|
||||
//! mem[26] = 1
|
||||
//! When this program goes to write to memory address 42, it first applies the bitmask:
|
||||
//!
|
||||
//! address: 000000000000000000000000000000101010 (decimal 42)
|
||||
//! mask: 000000000000000000000000000000X1001X
|
||||
//! result: 000000000000000000000000000000X1101X
|
||||
//! After applying the mask, four bits are overwritten, three of which are different, and two of which are floating. Floating bits take on every possible combination of values; with two floating bits, four actual memory addresses are written:
|
||||
//!
|
||||
//! 000000000000000000000000000000011010 (decimal 26)
|
||||
//! 000000000000000000000000000000011011 (decimal 27)
|
||||
//! 000000000000000000000000000000111010 (decimal 58)
|
||||
//! 000000000000000000000000000000111011 (decimal 59)
|
||||
//! Next, the program is about to write to memory address 26 with a different bitmask:
|
||||
//!
|
||||
//! address: 000000000000000000000000000000011010 (decimal 26)
|
||||
//! mask: 00000000000000000000000000000000X0XX
|
||||
//! result: 00000000000000000000000000000001X0XX
|
||||
//! This results in an address with three floating bits, causing writes to eight memory addresses:
|
||||
//!
|
||||
//! 000000000000000000000000000000010000 (decimal 16)
|
||||
//! 000000000000000000000000000000010001 (decimal 17)
|
||||
//! 000000000000000000000000000000010010 (decimal 18)
|
||||
//! 000000000000000000000000000000010011 (decimal 19)
|
||||
//! 000000000000000000000000000000011000 (decimal 24)
|
||||
//! 000000000000000000000000000000011001 (decimal 25)
|
||||
//! 000000000000000000000000000000011010 (decimal 26)
|
||||
//! 000000000000000000000000000000011011 (decimal 27)
|
||||
//! The entire 36-bit address space still begins initialized to the value 0 at every address, and you still need the sum of all values left in memory at the end of the program. In this example, the sum is 208.
|
||||
//!
|
||||
//! Execute the initialization program using an emulator for a version 2 decoder chip. What is the sum of all values left in memory after it completes?
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::aoc;
|
||||
|
||||
// Machine bit width.
|
||||
const BIT_WITDH: u8 = 36;
|
||||
#[derive(Default)]
|
||||
struct Mask {
|
||||
mask: usize,
|
||||
value: usize,
|
||||
}
|
||||
|
||||
impl FromStr for Mask {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Mask, ()> {
|
||||
let mut mask = 0;
|
||||
let mut value = 0;
|
||||
s.bytes().for_each(|v| match v {
|
||||
b'X' => {
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
value <<= 1;
|
||||
}
|
||||
b'1' => {
|
||||
mask <<= 1;
|
||||
value <<= 1;
|
||||
value |= 1;
|
||||
}
|
||||
b'0' => {
|
||||
mask <<= 1;
|
||||
value <<= 1;
|
||||
}
|
||||
c => panic!(format!("Unhandled mask character '{}'", c)),
|
||||
});
|
||||
Ok(Mask { mask, value })
|
||||
}
|
||||
}
|
||||
|
||||
impl Mask {
|
||||
fn apply(&self, v: usize) -> usize {
|
||||
v & self.mask | self.value
|
||||
}
|
||||
|
||||
// TODO(wathiede): make this an Iterator?
|
||||
fn decode(&self, v: usize) -> Vec<usize> {
|
||||
// Add decoded value with all floaters set to zero.
|
||||
let mut res = vec![(v | self.value) & !self.mask];
|
||||
for bit in 0..BIT_WITDH {
|
||||
let set = self.mask & (1 << bit);
|
||||
if set > 0 {
|
||||
// Floater
|
||||
let ext: Vec<_> = res.iter().map(|v| v | set).collect();
|
||||
res.extend(ext);
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
use std::fmt;
|
||||
impl fmt::Debug for Mask {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "mask: {:036b} value {:036b}", self.mask, self.value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
struct Address(usize);
|
||||
|
||||
impl FromStr for Address {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Address, ()> {
|
||||
Ok(Address(
|
||||
s.strip_prefix("mem[")
|
||||
.ok_or(())?
|
||||
.strip_suffix("]")
|
||||
.ok_or(())?
|
||||
.parse()
|
||||
.map_err(|_| ())?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc(day14, part1)]
|
||||
fn solution1(input: &str) -> usize {
|
||||
let mut mem: HashMap<usize, usize> = HashMap::new();
|
||||
let mut mask = Mask::default();
|
||||
|
||||
input.split('\n').for_each(|l| {
|
||||
let (cmd, arg) = l.split_at(l.find(" = ").expect("Couldn't find space wrapped ="));
|
||||
let arg = &arg[3..];
|
||||
match cmd {
|
||||
"mask" => mask = arg.parse().expect("Couldn't parse mask"),
|
||||
_ => {
|
||||
let addr: Address = cmd.parse().expect("Couldn't parse address");
|
||||
let val = mask.apply(arg.parse().expect("Couldn't pass arg"));
|
||||
mem.insert(addr.0, val);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
mem.values().fold(0, |acc, v| acc + v)
|
||||
}
|
||||
|
||||
#[aoc(day14, part2)]
|
||||
fn solution2(input: &str) -> usize {
|
||||
let mut mem: HashMap<usize, usize> = HashMap::new();
|
||||
let mut mask = Mask::default();
|
||||
|
||||
input.split('\n').for_each(|l| {
|
||||
let (cmd, arg) = l.split_at(l.find(" = ").expect("Couldn't find space wrapped ="));
|
||||
let arg = &arg[3..];
|
||||
match cmd {
|
||||
"mask" => mask = arg.parse().expect("Couldn't parse mask"),
|
||||
_ => {
|
||||
let addr: Address = cmd.parse().expect("Couldn't parse address");
|
||||
let val = arg.parse().expect("Couldn't pass arg");
|
||||
for dec_addr in mask.decode(addr.0) {
|
||||
mem.insert(dec_addr, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
mem.values().fold(0, |acc, v| acc + v)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT1: &'static str = r#"mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X
|
||||
mem[8] = 11
|
||||
mem[7] = 101
|
||||
mem[8] = 0"#;
|
||||
|
||||
#[test]
|
||||
fn test_solution1() {
|
||||
assert_eq!(solution1(INPUT1), 165);
|
||||
}
|
||||
const INPUT2: &'static str = r#"mask = 000000000000000000000000000000X1001X
|
||||
mem[42] = 100
|
||||
mask = 00000000000000000000000000000000X0XX
|
||||
mem[26] = 1"#;
|
||||
|
||||
#[test]
|
||||
fn test_solution2() {
|
||||
assert_eq!(solution2(INPUT2), 208);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mask_decode() {
|
||||
let m: Mask = "000000000000000000000000000000X1001X".parse().unwrap();
|
||||
assert_eq!(m.decode(42), vec![26, 27, 58, 59]);
|
||||
let m: Mask = "00000000000000000000000000000000X0XX".parse().unwrap();
|
||||
assert_eq!(m.decode(26), vec![16, 17, 18, 19, 24, 25, 26, 27]);
|
||||
}
|
||||
}
|
||||
167
2020/src/day15.rs
Normal file
167
2020/src/day15.rs
Normal file
@@ -0,0 +1,167 @@
|
||||
//! --- Day 15: Rambunctious Recitation ---
|
||||
//! You catch the airport shuttle and try to book a new flight to your vacation island. Due to the storm, all direct flights have been cancelled, but a route is available to get around the storm. You take it.
|
||||
//!
|
||||
//! While you wait for your flight, you decide to check in with the Elves back at the North Pole. They're playing a memory game and are ever so excited to explain the rules!
|
||||
//!
|
||||
//! In this game, the players take turns saying numbers. They begin by taking turns reading from a list of starting numbers (your puzzle input). Then, each turn consists of considering the most recently spoken number:
|
||||
//!
|
||||
//! If that was the first time the number has been spoken, the current player says 0.
|
||||
//! Otherwise, the number had been spoken before; the current player announces how many turns apart the number is from when it was previously spoken.
|
||||
//! So, after the starting numbers, each turn results in that player speaking aloud either 0 (if the last number is new) or an age (if the last number is a repeat).
|
||||
//!
|
||||
//! For example, suppose the starting numbers are 0,3,6:
|
||||
//!
|
||||
//! Turn 1: The 1st number spoken is a starting number, 0.
|
||||
//! Turn 2: The 2nd number spoken is a starting number, 3.
|
||||
//! Turn 3: The 3rd number spoken is a starting number, 6.
|
||||
//! Turn 4: Now, consider the last number spoken, 6. Since that was the first time the number had been spoken, the 4th number spoken is 0.
|
||||
//! Turn 5: Next, again consider the last number spoken, 0. Since it had been spoken before, the next number to speak is the difference between the turn number when it was last spoken (the previous turn, 4) and the turn number of the time it was most recently spoken before then (turn 1). Thus, the 5th number spoken is 4 - 1, 3.
|
||||
//! Turn 6: The last number spoken, 3 had also been spoken before, most recently on turns 5 and 2. So, the 6th number spoken is 5 - 2, 3.
|
||||
//! Turn 7: Since 3 was just spoken twice in a row, and the last two turns are 1 turn apart, the 7th number spoken is 1.
|
||||
//! Turn 8: Since 1 is new, the 8th number spoken is 0.
|
||||
//! Turn 9: 0 was last spoken on turns 8 and 4, so the 9th number spoken is the difference between them, 4.
|
||||
//! Turn 10: 4 is new, so the 10th number spoken is 0.
|
||||
//! (The game ends when the Elves get sick of playing or dinner is ready, whichever comes first.)
|
||||
//!
|
||||
//! Their question for you is: what will be the 2020th number spoken? In the example above, the 2020th number spoken will be 436.
|
||||
//!
|
||||
//! Here are a few more examples:
|
||||
//!
|
||||
//! Given the starting numbers 1,3,2, the 2020th number spoken is 1.
|
||||
//! Given the starting numbers 2,1,3, the 2020th number spoken is 10.
|
||||
//! Given the starting numbers 1,2,3, the 2020th number spoken is 27.
|
||||
//! Given the starting numbers 2,3,1, the 2020th number spoken is 78.
|
||||
//! Given the starting numbers 3,2,1, the 2020th number spoken is 438.
|
||||
//! Given the starting numbers 3,1,2, the 2020th number spoken is 1836.
|
||||
//! Given your starting numbers, what will be the 2020th number spoken?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! Impressed, the Elves issue you a challenge: determine the 30000000th number spoken. For example, given the same starting numbers as above:
|
||||
//!
|
||||
//! Given 0,3,6, the 30000000th number spoken is 175594.
|
||||
//! Given 1,3,2, the 30000000th number spoken is 2578.
|
||||
//! Given 2,1,3, the 30000000th number spoken is 3544142.
|
||||
//! Given 1,2,3, the 30000000th number spoken is 261214.
|
||||
//! Given 2,3,1, the 30000000th number spoken is 6895259.
|
||||
//! Given 3,2,1, the 30000000th number spoken is 18.
|
||||
//! Given 3,1,2, the 30000000th number spoken is 362.
|
||||
//! Given your starting numbers, what will be the 30000000th number spoken?
|
||||
|
||||
use aoc_runner_derive::aoc;
|
||||
|
||||
#[aoc(day15, part1)]
|
||||
fn solution1(input: &str) -> usize {
|
||||
const ANSWER_IDX: usize = 2020;
|
||||
let mut history = Vec::with_capacity(ANSWER_IDX);
|
||||
input
|
||||
.split(',')
|
||||
.map(|s| s.parse().expect("couldn't parse number"))
|
||||
.for_each(|n| history.push(n));
|
||||
let mut last = history[history.len() - 1];
|
||||
(history.len()..ANSWER_IDX).for_each(|i| {
|
||||
// Search backwards for the last number seen. If it's not found, we append 0 to history.
|
||||
// If it's found, we append the distance.
|
||||
let next = match history[..i - 1]
|
||||
.iter()
|
||||
.rev()
|
||||
.enumerate()
|
||||
.skip_while(|(_i, v)| **v != last)
|
||||
.map(|(i, _v)| i)
|
||||
.nth(0)
|
||||
{
|
||||
None => 0,
|
||||
Some(i) => i + 1,
|
||||
};
|
||||
history.push(next);
|
||||
last = next;
|
||||
});
|
||||
history[ANSWER_IDX - 1]
|
||||
}
|
||||
|
||||
#[aoc(day15, part2)]
|
||||
fn solution2(input: &str) -> usize {
|
||||
const ANSWER_IDX: usize = 30000000;
|
||||
solution2_impl(input, ANSWER_IDX)
|
||||
}
|
||||
|
||||
use std::collections::HashMap;
|
||||
fn solution2_impl(input: &str, idx: usize) -> usize {
|
||||
let starter: Vec<_> = input
|
||||
.split(',')
|
||||
.map(|s| s.parse().expect("couldn't parse number"))
|
||||
.collect();
|
||||
|
||||
let mut history: HashMap<usize, usize> = starter
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(i, n)| (n, i))
|
||||
.collect();
|
||||
|
||||
let mut last = 0;
|
||||
let mut spoken = 0;
|
||||
(history.len()..idx).for_each(|i| {
|
||||
match history.get_mut(&spoken) {
|
||||
Some(entry) => {
|
||||
last = spoken;
|
||||
spoken = i - *entry;
|
||||
*entry = i;
|
||||
}
|
||||
None => {
|
||||
last = spoken;
|
||||
history.insert(spoken, i);
|
||||
spoken = 0;
|
||||
}
|
||||
};
|
||||
});
|
||||
last
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_solution1() {
|
||||
for (input, want) in vec![
|
||||
("1,3,2", 1),
|
||||
("2,1,3", 10),
|
||||
("1,2,3", 27),
|
||||
("2,3,1", 78),
|
||||
("3,2,1", 438),
|
||||
("3,1,2", 1836),
|
||||
] {
|
||||
assert_eq!(solution1(input), want);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_solution2_impl() {
|
||||
for (input, want) in vec![
|
||||
("0,3,6", 436),
|
||||
("1,3,2", 1),
|
||||
("2,1,3", 10),
|
||||
("1,2,3", 27),
|
||||
("2,3,1", 78),
|
||||
("3,2,1", 438),
|
||||
("3,1,2", 1836),
|
||||
] {
|
||||
assert_eq!(solution2_impl(input, 2020), want);
|
||||
}
|
||||
}
|
||||
|
||||
// This is slow
|
||||
// #[test]
|
||||
// fn test_solution2() {
|
||||
// for (input, want) in vec![
|
||||
// //("0,3,6", 175594),
|
||||
// ("1,3,2", 2578),
|
||||
// ("2,1,3", 3544142),
|
||||
// ("1,2,3", 261214),
|
||||
// ("2,3,1", 6895259),
|
||||
// ("3,2,1", 18),
|
||||
// ("3,1,2", 362),
|
||||
// ] {
|
||||
// assert_eq!(solution2(input), want);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
365
2020/src/day16.rs
Normal file
365
2020/src/day16.rs
Normal file
@@ -0,0 +1,365 @@
|
||||
//! --- Day 16: Ticket Translation ---
|
||||
//! As you're walking to yet another connecting flight, you realize that one of the legs of your re-routed trip coming up is on a high-speed train. However, the train ticket you were given is in a language you don't understand. You should probably figure out what it says before you get to the train station after the next flight.
|
||||
//!
|
||||
//! Unfortunately, you can't actually read the words on the ticket. You can, however, read the numbers, and so you figure out the fields these tickets must have and the valid ranges for values in those fields.
|
||||
//!
|
||||
//! You collect the rules for ticket fields, the numbers on your ticket, and the numbers on other nearby tickets for the same train service (via the airport security cameras) together into a single document you can reference (your puzzle input).
|
||||
//!
|
||||
//! The rules for ticket fields specify a list of fields that exist somewhere on the ticket and the valid ranges of values for each field. For example, a rule like class: 1-3 or 5-7 means that one of the fields in every ticket is named class and can be any value in the ranges 1-3 or 5-7 (inclusive, such that 3 and 5 are both valid in this field, but 4 is not).
|
||||
//!
|
||||
//! Each ticket is represented by a single line of comma-separated values. The values are the numbers on the ticket in the order they appear; every ticket has the same format. For example, consider this ticket:
|
||||
//!
|
||||
//! .--------------------------------------------------------.
|
||||
//! | ????: 101 ?????: 102 ??????????: 103 ???: 104 |
|
||||
//! | |
|
||||
//! | ??: 301 ??: 302 ???????: 303 ??????? |
|
||||
//! | ??: 401 ??: 402 ???? ????: 403 ????????? |
|
||||
//! '--------------------------------------------------------'
|
||||
//! Here, ? represents text in a language you don't understand. This ticket might be represented as 101,102,103,104,301,302,303,401,402,403; of course, the actual train tickets you're looking at are much more complicated. In any case, you've extracted just the numbers in such a way that the first number is always the same specific field, the second number is always a different specific field, and so on - you just don't know what each position actually means!
|
||||
//!
|
||||
//! Start by determining which tickets are completely invalid; these are tickets that contain values which aren't valid for any field. Ignore your ticket for now.
|
||||
//!
|
||||
//! For example, suppose you have the following notes:
|
||||
//!
|
||||
//! class: 1-3 or 5-7
|
||||
//! row: 6-11 or 33-44
|
||||
//! seat: 13-40 or 45-50
|
||||
//!
|
||||
//! your ticket:
|
||||
//! 7,1,14
|
||||
//!
|
||||
//! nearby tickets:
|
||||
//! 7,3,47
|
||||
//! 40,4,50
|
||||
//! 55,2,20
|
||||
//! 38,6,12
|
||||
//! It doesn't matter which position corresponds to which field; you can identify invalid nearby tickets by considering only whether tickets contain values that are not valid for any field. In this example, the values on the first nearby ticket are all valid for at least one field. This is not true of the other three nearby tickets: the values 4, 55, and 12 are are not valid for any field. Adding together all of the invalid values produces your ticket scanning error rate: 4 + 55 + 12 = 71.
|
||||
//!
|
||||
//! Consider the validity of the nearby tickets you scanned. What is your ticket scanning error rate?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! Now that you've identified which tickets contain invalid values, discard those tickets entirely. Use the remaining valid tickets to determine which field is which.
|
||||
//!
|
||||
//! Using the valid ranges for each field, determine what order the fields appear on the tickets. The order is consistent between all tickets: if seat is the third field, it is the third field on every ticket, including your ticket.
|
||||
//!
|
||||
//! For example, suppose you have the following notes:
|
||||
//!
|
||||
//! class: 0-1 or 4-19
|
||||
//! row: 0-5 or 8-19
|
||||
//! seat: 0-13 or 16-19
|
||||
//!
|
||||
//! your ticket:
|
||||
//! 11,12,13
|
||||
//!
|
||||
//! nearby tickets:
|
||||
//! 3,9,18
|
||||
//! 15,1,5
|
||||
//! 5,14,9
|
||||
//! Based on the nearby tickets in the above example, the first position must be row, the second position must be class, and the third position must be seat; you can conclude that in your ticket, class is 12, row is 11, and seat is 13.
|
||||
//!
|
||||
//! Once you work out which field is which, look for the six fields on your ticket that start with the word departure. What do you get if you multiply those six values together?
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Range;
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Rule {
|
||||
name: String,
|
||||
low: Range<usize>,
|
||||
high: Range<usize>,
|
||||
}
|
||||
|
||||
/// Parses "2-4" into Range(2..5).
|
||||
fn from_range(s: &str) -> Result<Range<usize>, String> {
|
||||
let mut it = s.split('-');
|
||||
let low = it
|
||||
.next()
|
||||
.ok_or("low range".to_string())?
|
||||
.parse()
|
||||
.map_err(|e| format!("{}", e))?;
|
||||
let high = it
|
||||
.next()
|
||||
.ok_or("high range".to_string())?
|
||||
.parse::<usize>()
|
||||
.map_err(|e| format!("{}", e))?;
|
||||
Ok(low..high + 1)
|
||||
}
|
||||
|
||||
impl FromStr for Rule {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Rule, String> {
|
||||
let c_idx = s.find(":").expect("missing :");
|
||||
let name = s[..c_idx].to_string();
|
||||
let mut it = s[c_idx + 2..].split(' ');
|
||||
let low = from_range(it.next().ok_or("get low")?)?;
|
||||
let _ = it.next().ok_or("missing 'or'".to_string())?;
|
||||
let high = from_range(it.next().ok_or("get high")?)?;
|
||||
Ok(Rule { name, low, high })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Ticket {
|
||||
nums: Vec<usize>,
|
||||
}
|
||||
|
||||
impl FromStr for Ticket {
|
||||
type Err = String;
|
||||
fn from_str(s: &str) -> Result<Ticket, String> {
|
||||
Ok(Ticket {
|
||||
nums: s
|
||||
.split(',')
|
||||
.map(|s| s.parse().map_err(|e| format!("{}", e)))
|
||||
.collect::<Result<Vec<_>, String>>()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn reduce_possibilities(possibilities: HashMap<usize, Vec<String>>) -> HashMap<usize, String> {
|
||||
let mut p = possibilities.clone();
|
||||
let mut uniq = HashMap::new();
|
||||
|
||||
loop {
|
||||
let mut rm = Vec::new();
|
||||
// Extract all the columns with only one possible answer.
|
||||
p.iter().for_each(|(k, v)| {
|
||||
if v.len() == 1 {
|
||||
let word = v[0].to_string();
|
||||
rm.push(word.to_string());
|
||||
uniq.insert(*k, word);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove all the assigned columns from columns that have multiple possibilities.
|
||||
p = p
|
||||
.into_iter()
|
||||
.filter_map(|(k, v)| {
|
||||
let v: Vec<_> = v.into_iter().filter(|w| !rm.contains(w)).collect();
|
||||
if v.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some((k, v))
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if p.is_empty() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uniq
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Notes {
|
||||
rules: Vec<Rule>,
|
||||
my: Ticket,
|
||||
nearby: Vec<Ticket>,
|
||||
}
|
||||
|
||||
impl Notes {
|
||||
fn valid(&self, n: usize) -> bool {
|
||||
for r in &self.rules {
|
||||
if r.low.contains(&n) || r.high.contains(&n) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn valid_ticket(&self, t: &Ticket) -> bool {
|
||||
t.nums.iter().all(|n| self.valid(*n))
|
||||
}
|
||||
|
||||
fn invalid_nums(&self, t: &Ticket) -> Vec<usize> {
|
||||
t.nums
|
||||
.iter()
|
||||
.filter(|n| !self.valid(**n))
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn valid_column<'a, I>(&self, idx: usize, mut tickets: I, r: &Rule) -> bool
|
||||
where
|
||||
I: Iterator<Item = &'a &'a Ticket>,
|
||||
{
|
||||
tickets.all(|t| r.low.contains(&t.nums[idx]) || r.high.contains(&t.nums[idx]))
|
||||
}
|
||||
|
||||
/// translate will apply `rules` to all valid tickets to compute which column maps to each
|
||||
/// rule.
|
||||
fn translate(&self) -> HashMap<String, usize> {
|
||||
let valid_tickets: Vec<_> = self
|
||||
.nearby
|
||||
.iter()
|
||||
.filter(|t| self.valid_ticket(t))
|
||||
.collect();
|
||||
use std::iter::once;
|
||||
let possibilities: HashMap<_, _> = (0..self.my.nums.len())
|
||||
.map(|i| {
|
||||
let possible = self
|
||||
.rules
|
||||
.iter()
|
||||
.filter(|r| {
|
||||
self.valid_column(i, once(&&self.my).chain(valid_tickets.iter()), r)
|
||||
})
|
||||
.map(|r| r.name.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
(i, possible)
|
||||
})
|
||||
.collect();
|
||||
|
||||
reduce_possibilities(possibilities)
|
||||
.into_iter()
|
||||
.map(|(i, name)| (name, i))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day16)]
|
||||
fn parse1(input: &str) -> Notes {
|
||||
let mut it = input.split("\n\n");
|
||||
let rules: Vec<Rule> = it
|
||||
.next()
|
||||
.expect("EOF1")
|
||||
.split('\n')
|
||||
.map(|l| l.parse().expect("rules"))
|
||||
.collect();
|
||||
let my: Ticket = it
|
||||
.next()
|
||||
.expect("EOF2")
|
||||
.split('\n')
|
||||
.skip(1)
|
||||
.nth(0)
|
||||
.map(|l| l.parse().expect("my parse"))
|
||||
.expect("my");
|
||||
let nearby: Vec<Ticket> = it
|
||||
.next()
|
||||
.expect("EOF3")
|
||||
.split('\n')
|
||||
.skip(1)
|
||||
.map(|l| l.parse().expect("rules"))
|
||||
.collect();
|
||||
Notes { rules, my, nearby }
|
||||
}
|
||||
|
||||
#[aoc(day16, part1)]
|
||||
fn solution1(notes: &Notes) -> usize {
|
||||
notes
|
||||
.nearby
|
||||
.iter()
|
||||
.flat_map(|t| notes.invalid_nums(t))
|
||||
.sum()
|
||||
}
|
||||
|
||||
#[aoc(day16, part2)]
|
||||
fn solution2(notes: &Notes) -> usize {
|
||||
let t = notes.translate();
|
||||
let idxs: Vec<_> = t
|
||||
.iter()
|
||||
.filter_map(|(k, v)| {
|
||||
if k.starts_with("departure") {
|
||||
Some(v)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
idxs.into_iter().map(|i| notes.my.nums[*i]).product()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const INPUT1: &'static str = r#"class: 1-3 or 5-7
|
||||
row: 6-11 or 33-44
|
||||
seat: 13-40 or 45-50
|
||||
|
||||
your ticket:
|
||||
7,1,14
|
||||
|
||||
nearby tickets:
|
||||
7,3,47
|
||||
40,4,50
|
||||
55,2,20
|
||||
38,6,12"#;
|
||||
|
||||
#[test]
|
||||
fn test_parse1() {
|
||||
assert_eq!(
|
||||
parse1(INPUT1),
|
||||
Notes {
|
||||
rules: vec![
|
||||
Rule {
|
||||
name: "class".to_string(),
|
||||
low: 1..4,
|
||||
high: 5..8,
|
||||
},
|
||||
Rule {
|
||||
name: "row".to_string(),
|
||||
low: 6..12,
|
||||
high: 33..45,
|
||||
},
|
||||
Rule {
|
||||
name: "seat".to_string(),
|
||||
low: 13..41,
|
||||
high: 45..51,
|
||||
},
|
||||
],
|
||||
my: Ticket {
|
||||
nums: vec![7, 1, 14],
|
||||
},
|
||||
nearby: vec![
|
||||
Ticket {
|
||||
nums: vec![7, 3, 47]
|
||||
},
|
||||
Ticket {
|
||||
nums: vec![40, 4, 50]
|
||||
},
|
||||
Ticket {
|
||||
nums: vec![55, 2, 20]
|
||||
},
|
||||
Ticket {
|
||||
nums: vec![38, 6, 12]
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_solution1() {
|
||||
assert_eq!(solution1(&parse1(INPUT1)), 4 + 55 + 12);
|
||||
}
|
||||
|
||||
const INPUT2: &'static str = r#"class: 0-1 or 4-19
|
||||
row: 0-5 or 8-19
|
||||
seat: 0-13 or 16-19
|
||||
|
||||
your ticket:
|
||||
11,12,13
|
||||
|
||||
nearby tickets:
|
||||
3,9,18
|
||||
15,1,5
|
||||
5,14,9"#;
|
||||
|
||||
#[test]
|
||||
fn translate() {
|
||||
let notes = parse1(&INPUT2);
|
||||
assert_eq!(
|
||||
notes.translate(),
|
||||
vec![
|
||||
("class".to_string(), 1),
|
||||
("row".to_string(), 0),
|
||||
("seat".to_string(), 2),
|
||||
]
|
||||
.into_iter()
|
||||
.collect::<HashMap<String, usize>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
813
2020/src/day17.rs
Normal file
813
2020/src/day17.rs
Normal file
@@ -0,0 +1,813 @@
|
||||
//! --- Day 17: Conway Cubes ---
|
||||
//! As your flight slowly drifts through the sky, the Elves at the Mythical Information Bureau at the North Pole contact you. They'd like some help debugging a malfunctioning experimental energy source aboard one of their super-secret imaging satellites.
|
||||
//!
|
||||
//! The experimental energy source is based on cutting-edge technology: a set of Conway Cubes contained in a pocket dimension! When you hear it's having problems, you can't help but agree to take a look.
|
||||
//!
|
||||
//! The pocket dimension contains an infinite 3-dimensional grid. At every integer 3-dimensional coordinate (x,y,z), there exists a single cube which is either active or inactive.
|
||||
//!
|
||||
//! In the initial state of the pocket dimension, almost all cubes start inactive. The only exception to this is a small flat region of cubes (your puzzle input); the cubes in this region start in the specified active (#) or inactive (.) state.
|
||||
//!
|
||||
//! The energy source then proceeds to boot up by executing six cycles.
|
||||
//!
|
||||
//! Each cube only ever considers its neighbors: any of the 26 other cubes where any of their coordinates differ by at most 1. For example, given the cube at x=1,y=2,z=3, its neighbors include the cube at x=2,y=2,z=2, the cube at x=0,y=2,z=3, and so on.
|
||||
//!
|
||||
//! During a cycle, all cubes simultaneously change their state according to the following rules:
|
||||
//!
|
||||
//! If a cube is active and exactly 2 or 3 of its neighbors are also active, the cube remains active. Otherwise, the cube becomes inactive.
|
||||
//! If a cube is inactive but exactly 3 of its neighbors are active, the cube becomes active. Otherwise, the cube remains inactive.
|
||||
//! The engineers responsible for this experimental energy source would like you to simulate the pocket dimension and determine what the configuration of cubes should be at the end of the six-cycle boot process.
|
||||
//!
|
||||
//! For example, consider the following initial state:
|
||||
//!
|
||||
//! .#.
|
||||
//! ..#
|
||||
//! ###
|
||||
//! Even though the pocket dimension is 3-dimensional, this initial state represents a small 2-dimensional slice of it. (In particular, this initial state defines a 3x3x1 region of the 3-dimensional space.)
|
||||
//!
|
||||
//! Simulating a few cycles from this initial state produces the following configurations, where the result of each cycle is shown layer-by-layer at each given z coordinate (and the frame of view follows the active cells in each cycle):
|
||||
//!
|
||||
//! Before any cycles:
|
||||
//!
|
||||
//! z=0
|
||||
//! .#.
|
||||
//! ..#
|
||||
//! ###
|
||||
//!
|
||||
//!
|
||||
//! After 1 cycle:
|
||||
//!
|
||||
//! z=-1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=0
|
||||
//! #.#
|
||||
//! .##
|
||||
//! .#.
|
||||
//!
|
||||
//! z=1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//!
|
||||
//! After 2 cycles:
|
||||
//!
|
||||
//! z=-2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-1
|
||||
//! ..#..
|
||||
//! .#..#
|
||||
//! ....#
|
||||
//! .#...
|
||||
//! .....
|
||||
//!
|
||||
//! z=0
|
||||
//! ##...
|
||||
//! ##...
|
||||
//! #....
|
||||
//! ....#
|
||||
//! .###.
|
||||
//!
|
||||
//! z=1
|
||||
//! ..#..
|
||||
//! .#..#
|
||||
//! ....#
|
||||
//! .#...
|
||||
//! .....
|
||||
//!
|
||||
//! z=2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//!
|
||||
//! After 3 cycles:
|
||||
//!
|
||||
//! z=-2
|
||||
//! .......
|
||||
//! .......
|
||||
//! ..##...
|
||||
//! ..###..
|
||||
//! .......
|
||||
//! .......
|
||||
//! .......
|
||||
//!
|
||||
//! z=-1
|
||||
//! ..#....
|
||||
//! ...#...
|
||||
//! #......
|
||||
//! .....##
|
||||
//! .#...#.
|
||||
//! ..#.#..
|
||||
//! ...#...
|
||||
//!
|
||||
//! z=0
|
||||
//! ...#...
|
||||
//! .......
|
||||
//! #......
|
||||
//! .......
|
||||
//! .....##
|
||||
//! .##.#..
|
||||
//! ...#...
|
||||
//!
|
||||
//! z=1
|
||||
//! ..#....
|
||||
//! ...#...
|
||||
//! #......
|
||||
//! .....##
|
||||
//! .#...#.
|
||||
//! ..#.#..
|
||||
//! ...#...
|
||||
//!
|
||||
//! z=2
|
||||
//! .......
|
||||
//! .......
|
||||
//! ..##...
|
||||
//! ..###..
|
||||
//! .......
|
||||
//! .......
|
||||
//! .......
|
||||
//! After the full six-cycle boot process completes, 112 cubes are left in the active state.
|
||||
//!
|
||||
//! Starting with your given initial configuration, simulate six cycles. How many cubes are left in the active state after the sixth cycle?
|
||||
|
||||
//! --- Part Two ---
|
||||
//! For some reason, your simulated results don't match what the experimental energy source engineers expected. Apparently, the pocket dimension actually has four spatial dimensions, not three.
|
||||
//!
|
||||
//! The pocket dimension contains an infinite 4-dimensional grid. At every integer 4-dimensional coordinate (x,y,z,w), there exists a single cube (really, a hypercube) which is still either active or inactive.
|
||||
//!
|
||||
//! Each cube only ever considers its neighbors: any of the 80 other cubes where any of their coordinates differ by at most 1. For example, given the cube at x=1,y=2,z=3,w=4, its neighbors include the cube at x=2,y=2,z=3,w=3, the cube at x=0,y=2,z=3,w=4, and so on.
|
||||
//!
|
||||
//! The initial state of the pocket dimension still consists of a small flat region of cubes. Furthermore, the same rules for cycle updating still apply: during each cycle, consider the number of active neighbors of each cube.
|
||||
//!
|
||||
//! For example, consider the same initial state as in the example above. Even though the pocket dimension is 4-dimensional, this initial state represents a small 2-dimensional slice of it. (In particular, this initial state defines a 3x3x1x1 region of the 4-dimensional space.)
|
||||
//!
|
||||
//! Simulating a few cycles from this initial state produces the following configurations, where the result of each cycle is shown layer-by-layer at each given z and w coordinate:
|
||||
//!
|
||||
//! Before any cycles:
|
||||
//!
|
||||
//! z=0, w=0
|
||||
//! .#.
|
||||
//! ..#
|
||||
//! ###
|
||||
//!
|
||||
//!
|
||||
//! After 1 cycle:
|
||||
//!
|
||||
//! z=-1, w=-1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=0, w=-1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=1, w=-1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=-1, w=0
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=0, w=0
|
||||
//! #.#
|
||||
//! .##
|
||||
//! .#.
|
||||
//!
|
||||
//! z=1, w=0
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=-1, w=1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=0, w=1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//! z=1, w=1
|
||||
//! #..
|
||||
//! ..#
|
||||
//! .#.
|
||||
//!
|
||||
//!
|
||||
//! After 2 cycles:
|
||||
//!
|
||||
//! z=-2, w=-2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-1, w=-2
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=0, w=-2
|
||||
//! ###..
|
||||
//! ##.##
|
||||
//! #...#
|
||||
//! .#..#
|
||||
//! .###.
|
||||
//!
|
||||
//! z=1, w=-2
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=2, w=-2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-2, w=-1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-1, w=-1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=0, w=-1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=1, w=-1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=2, w=-1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-2, w=0
|
||||
//! ###..
|
||||
//! ##.##
|
||||
//! #...#
|
||||
//! .#..#
|
||||
//! .###.
|
||||
//!
|
||||
//! z=-1, w=0
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=0, w=0
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=1, w=0
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=2, w=0
|
||||
//! ###..
|
||||
//! ##.##
|
||||
//! #...#
|
||||
//! .#..#
|
||||
//! .###.
|
||||
//!
|
||||
//! z=-2, w=1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-1, w=1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=0, w=1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=1, w=1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=2, w=1
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-2, w=2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=-1, w=2
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=0, w=2
|
||||
//! ###..
|
||||
//! ##.##
|
||||
//! #...#
|
||||
//! .#..#
|
||||
//! .###.
|
||||
//!
|
||||
//! z=1, w=2
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//! .....
|
||||
//!
|
||||
//! z=2, w=2
|
||||
//! .....
|
||||
//! .....
|
||||
//! ..#..
|
||||
//! .....
|
||||
//! .....
|
||||
//! After the full six-cycle boot process completes, 848 cubes are left in the active state.
|
||||
//!
|
||||
//! Starting with your given initial configuration, simulate six cycles in a 4-dimensional space. How many cubes are left in the active state after the sixth cycle?
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
enum Cube {
|
||||
Active = b'#',
|
||||
Inactive = b'.',
|
||||
}
|
||||
impl fmt::Debug for Cube {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
Cube::Active => '#',
|
||||
Cube::Inactive => '.',
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
struct Universe<T> {
|
||||
cells: Vec<T>,
|
||||
x_len: usize,
|
||||
y_len: usize,
|
||||
z_len: usize,
|
||||
w_len: usize,
|
||||
default: T,
|
||||
}
|
||||
|
||||
impl<T> Universe<T> {
|
||||
fn dimensions(&self) -> String {
|
||||
let u = &self;
|
||||
format!("{}x{}x{}x{}", u.x_len, u.y_len, u.z_len, u.w_len)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Universe<T>
|
||||
where
|
||||
T: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}\n", self.dimensions())?;
|
||||
let u = &self;
|
||||
for w in 0..u.w_len {
|
||||
for z in 0..u.z_len {
|
||||
let hdr = format!(
|
||||
"z={}, w={}",
|
||||
z as isize - u.z_len as isize / 2,
|
||||
w as isize - u.w_len as isize / 2
|
||||
);
|
||||
write!(f, "{:width$} | ", hdr, width = u.x_len)?;
|
||||
}
|
||||
write!(f, "\n")?;
|
||||
for y in 0..u.y_len {
|
||||
for z in 0..u.z_len {
|
||||
for x in 0..u.x_len {
|
||||
write!(f, "{:?}", u[(x, y, z, w)])?;
|
||||
}
|
||||
write!(f, " | ")?;
|
||||
}
|
||||
write!(f, "\n")?;
|
||||
}
|
||||
write!(f, "\n")?;
|
||||
}
|
||||
write!(f, "\n")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
impl<T> IndexMut<(usize, usize, usize, usize)> for Universe<T> {
|
||||
fn index_mut(&mut self, (x, y, z, w): (usize, usize, usize, usize)) -> &mut Self::Output {
|
||||
if x >= self.x_len || y >= self.y_len || z > self.z_len || w > self.w_len {
|
||||
panic!(format!(
|
||||
"index_mut outside of bounds ({},{},{},{})",
|
||||
x, y, z, w
|
||||
));
|
||||
}
|
||||
&mut self.cells[x
|
||||
+ y * self.y_len
|
||||
+ z * self.x_len * self.y_len
|
||||
+ w * self.x_len * self.y_len * self.z_len]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Index<(usize, usize, usize, usize)> for Universe<T> {
|
||||
type Output = T;
|
||||
|
||||
/// Returns the value in 4-space given by x,y,z,w. Values outside the active space this Universe covers will return the default for T;
|
||||
fn index(&self, (x, y, z, w): (usize, usize, usize, usize)) -> &Self::Output {
|
||||
if x >= self.x_len || y >= self.y_len || z > self.z_len || w > self.w_len {
|
||||
return &self.default;
|
||||
}
|
||||
&self.cells[x
|
||||
+ y * self.y_len
|
||||
+ z * self.x_len * self.y_len
|
||||
+ w * self.x_len * self.y_len * self.z_len]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Index<(isize, isize, isize, isize)> for Universe<T> {
|
||||
type Output = T;
|
||||
|
||||
/// Returns the value in 4-space given by x,y,z,w. Values outside the active space this Universe covers will return self.default;
|
||||
fn index(&self, (x, y, z, w): (isize, isize, isize, isize)) -> &Self::Output {
|
||||
if x < 0 || y < 0 || z < 0 || w < 0 {
|
||||
return &self.default;
|
||||
}
|
||||
|
||||
let x_len = self.x_len as isize;
|
||||
let y_len = self.y_len as isize;
|
||||
let z_len = self.z_len as isize;
|
||||
let w_len = self.w_len as isize;
|
||||
|
||||
if x >= x_len || y >= y_len || z >= z_len || w >= w_len {
|
||||
return &self.default;
|
||||
}
|
||||
|
||||
&self.cells[(x + y * y_len + z * x_len * y_len + w * x_len * y_len * z_len) as usize]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct PocketDimension {
|
||||
universe: Universe<Cube>,
|
||||
}
|
||||
|
||||
impl std::str::FromStr for PocketDimension {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<PocketDimension, ()> {
|
||||
let mut cells = Vec::new();
|
||||
let z_layers: Vec<_> = s.split("\n\n").collect();
|
||||
let z_len = z_layers.len();
|
||||
let mut x_len = 0;
|
||||
let mut y_len = 0;
|
||||
z_layers.iter().for_each(|layer| {
|
||||
let rows: Vec<_> = layer.split('\n').map(|s| s.trim()).collect();
|
||||
y_len = rows.len();
|
||||
rows.iter().for_each(|row| {
|
||||
x_len = row.len();
|
||||
// TODO(wathiede): Is there something better here given we're using an enum with a
|
||||
// repr(u8)?
|
||||
cells.extend(row.bytes().filter(|c| c != &b'\n').map(|c| match c {
|
||||
b'#' => Cube::Active,
|
||||
b'.' => Cube::Inactive,
|
||||
c => panic!(format!("Unknown state '{}'", c)),
|
||||
}));
|
||||
});
|
||||
});
|
||||
let universe = Universe {
|
||||
cells,
|
||||
x_len,
|
||||
y_len,
|
||||
z_len,
|
||||
w_len: 1,
|
||||
default: Cube::Inactive,
|
||||
};
|
||||
|
||||
Ok(PocketDimension { universe })
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for PocketDimension {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self.universe)
|
||||
}
|
||||
}
|
||||
|
||||
impl PocketDimension {
|
||||
/// Applies the rules of the puzzle one iteration and returns a new PocketDimension
|
||||
/// representing the new state.
|
||||
fn step(&self, expand_w: bool) -> PocketDimension {
|
||||
let u = &self.universe;
|
||||
let x_len = u.x_len as isize;
|
||||
let y_len = u.y_len as isize;
|
||||
let z_len = u.z_len as isize;
|
||||
let w_len = u.w_len as isize;
|
||||
|
||||
let (new_w_len, w_range, w_off) = if expand_w {
|
||||
(u.w_len + 2, -1..w_len + 1, 1)
|
||||
} else {
|
||||
(u.w_len, 0..w_len, 0)
|
||||
};
|
||||
|
||||
let mut counts = Universe::<usize> {
|
||||
x_len: u.x_len + 2,
|
||||
y_len: u.y_len + 2,
|
||||
z_len: u.z_len + 2,
|
||||
w_len: new_w_len,
|
||||
cells: vec![0; (u.x_len + 2) * (u.y_len + 2) * (u.z_len + 2) * (new_w_len)],
|
||||
default: 0,
|
||||
};
|
||||
let mut universe = Universe::<Cube> {
|
||||
x_len: u.x_len + 2,
|
||||
y_len: u.y_len + 2,
|
||||
z_len: u.z_len + 2,
|
||||
w_len: new_w_len,
|
||||
cells: vec![
|
||||
Cube::Inactive;
|
||||
(u.x_len + 2) * (u.y_len + 2) * (u.z_len + 2) * (new_w_len)
|
||||
],
|
||||
default: Cube::Inactive,
|
||||
};
|
||||
for w in w_range {
|
||||
for z in -1..z_len + 1 {
|
||||
for y in -1..y_len + 1 {
|
||||
for x in -1..x_len + 1 {
|
||||
let adj = self.adjacency((x, y, z, w));
|
||||
let dst = (
|
||||
(x + 1) as usize,
|
||||
(y + 1) as usize,
|
||||
(z + 1) as usize,
|
||||
(w + w_off) as usize,
|
||||
);
|
||||
counts[dst] = adj;
|
||||
match self.universe[(x, y, z, w)] {
|
||||
Cube::Active => {
|
||||
if adj == 2 || adj == 3 {
|
||||
universe[dst] = Cube::Active;
|
||||
} else {
|
||||
universe[dst] = Cube::Inactive;
|
||||
}
|
||||
}
|
||||
Cube::Inactive => {
|
||||
if adj == 3 {
|
||||
universe[dst] = Cube::Active;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//dbg!(&counts, &universe);
|
||||
PocketDimension { universe }
|
||||
}
|
||||
fn active(&self) -> usize {
|
||||
self.universe
|
||||
.cells
|
||||
.iter()
|
||||
.filter(|c| c == &&Cube::Active)
|
||||
.count()
|
||||
}
|
||||
/// Counts active neighbors.
|
||||
fn adjacency(&self, (x, y, z, w): (isize, isize, isize, isize)) -> usize {
|
||||
let mut sum = 0;
|
||||
for w_off in -1..=1 {
|
||||
for z_off in -1..=1 {
|
||||
for y_off in -1..=1 {
|
||||
for x_off in -1..=1 {
|
||||
if x_off == 0 && y_off == 0 && z_off == 0 && w_off == 0 {
|
||||
// Skip the requested cell
|
||||
continue;
|
||||
}
|
||||
if self.universe[(x + x_off, y + y_off, z + z_off, w + w_off)]
|
||||
== Cube::Active
|
||||
{
|
||||
sum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sum
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day17)]
|
||||
fn generator(input: &str) -> PocketDimension {
|
||||
input.parse().expect("Couldn't parse initial state")
|
||||
}
|
||||
|
||||
#[aoc(day17, part1)]
|
||||
fn solution1(pd: &PocketDimension) -> usize {
|
||||
(0..6).fold(pd.clone(), |acc, _| acc.step(false)).active()
|
||||
}
|
||||
|
||||
#[aoc(day17, part2)]
|
||||
fn solution2(pd: &PocketDimension) -> usize {
|
||||
(0..6).fold(pd.clone(), |acc, _| acc.step(true)).active()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const INPUT1: &'static str = r#".#.
|
||||
..#
|
||||
###"#;
|
||||
|
||||
const STEPS1: &'static str = r#".#.
|
||||
..#
|
||||
###
|
||||
|
||||
|
||||
#..
|
||||
..#
|
||||
.#.
|
||||
|
||||
#.#
|
||||
.##
|
||||
.#.
|
||||
|
||||
#..
|
||||
..#
|
||||
.#.
|
||||
|
||||
|
||||
.....
|
||||
.....
|
||||
..#..
|
||||
.....
|
||||
.....
|
||||
|
||||
..#..
|
||||
.#..#
|
||||
....#
|
||||
.#...
|
||||
.....
|
||||
|
||||
##...
|
||||
##...
|
||||
#....
|
||||
....#
|
||||
.###.
|
||||
|
||||
..#..
|
||||
.#..#
|
||||
....#
|
||||
.#...
|
||||
.....
|
||||
|
||||
.....
|
||||
.....
|
||||
..#..
|
||||
.....
|
||||
.....
|
||||
|
||||
|
||||
.......
|
||||
.......
|
||||
..##...
|
||||
..###..
|
||||
.......
|
||||
.......
|
||||
.......
|
||||
|
||||
..#....
|
||||
...#...
|
||||
#......
|
||||
.....##
|
||||
.#...#.
|
||||
..#.#..
|
||||
...#...
|
||||
|
||||
...#...
|
||||
.......
|
||||
#......
|
||||
.......
|
||||
.....##
|
||||
.##.#..
|
||||
...#...
|
||||
|
||||
..#....
|
||||
...#...
|
||||
#......
|
||||
.....##
|
||||
.#...#.
|
||||
..#.#..
|
||||
...#...
|
||||
|
||||
.......
|
||||
.......
|
||||
..##...
|
||||
..###..
|
||||
.......
|
||||
.......
|
||||
......."#;
|
||||
|
||||
#[test]
|
||||
fn parse_and_count() {
|
||||
for (idx, ((input, active), dimensions)) in STEPS1
|
||||
.split("\n\n\n")
|
||||
.zip(vec![5, 11, 21, 38])
|
||||
.zip(vec!["3x3x1x1", "3x3x3x1", "5x5x5x1", "7x7x5x1"])
|
||||
.enumerate()
|
||||
{
|
||||
let pd = generator(input);
|
||||
assert_eq!(pd.active(), active);
|
||||
assert_eq!(
|
||||
pd.universe.dimensions(),
|
||||
dimensions,
|
||||
"idx {}: {:?}",
|
||||
idx,
|
||||
pd,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&generator(INPUT1)), 112);
|
||||
}
|
||||
#[test]
|
||||
fn step_exand_w() {
|
||||
let pd = generator(INPUT1);
|
||||
assert_eq!(pd.active(), 5);
|
||||
let pd = pd.step(true);
|
||||
assert_eq!(pd.active(), 29);
|
||||
let pd = pd.step(true);
|
||||
assert_eq!(pd.active(), 60);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(&generator(INPUT1)), 848);
|
||||
}
|
||||
}
|
||||
339
2020/src/day18.rs
Normal file
339
2020/src/day18.rs
Normal file
@@ -0,0 +1,339 @@
|
||||
//! --- Day 18: Operation Order ---
|
||||
//! As you look out the window and notice a heavily-forested continent slowly appear over the horizon, you are interrupted by the child sitting next to you. They're curious if you could help them with their math homework.
|
||||
//!
|
||||
//! Unfortunately, it seems like this "math" follows different rules than you remember.
|
||||
//!
|
||||
//! The homework (your puzzle input) consists of a series of expressions that consist of addition (+), multiplication (*), and parentheses ((...)). Just like normal math, parentheses indicate that the expression inside must be evaluated before it can be used by the surrounding expression. Addition still finds the sum of the numbers on both sides of the operator, and multiplication still finds the product.
|
||||
//!
|
||||
//! However, the rules of operator precedence have changed. Rather than evaluating multiplication before addition, the operators have the same precedence, and are evaluated left-to-right regardless of the order in which they appear.
|
||||
//!
|
||||
//! For example, the steps to evaluate the expression 1 + 2 * 3 + 4 * 5 + 6 are as follows:
|
||||
//!
|
||||
//! 1 + 2 * 3 + 4 * 5 + 6
|
||||
//! 3 * 3 + 4 * 5 + 6
|
||||
//! 9 + 4 * 5 + 6
|
||||
//! 13 * 5 + 6
|
||||
//! 65 + 6
|
||||
//! 71
|
||||
//! Parentheses can override this order; for example, here is what happens if parentheses are added to form 1 + (2 * 3) + (4 * (5 + 6)):
|
||||
//!
|
||||
//! 1 + (2 * 3) + (4 * (5 + 6))
|
||||
//! 1 + 6 + (4 * (5 + 6))
|
||||
//! 7 + (4 * (5 + 6))
|
||||
//! 7 + (4 * 11 )
|
||||
//! 7 + 44
|
||||
//! 51
|
||||
//! Here are a few more examples:
|
||||
//!
|
||||
//! 2 * 3 + (4 * 5) becomes 26.
|
||||
//! 5 + (8 * 3 + 9 + 3 * 4 * 3) becomes 437.
|
||||
//! 5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4)) becomes 12240.
|
||||
//! ((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2 becomes 13632.
|
||||
//! Before you can help with the homework, you need to understand it yourself. Evaluate the expression on each line of the homework; what is the sum of the resulting values?
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum Token {
|
||||
Num(u32),
|
||||
Add,
|
||||
Mul,
|
||||
Open,
|
||||
Close,
|
||||
Space,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum Ast {
|
||||
Add(Box<Ast>, Box<Ast>),
|
||||
Mul(Box<Ast>, Box<Ast>),
|
||||
Num(u32),
|
||||
}
|
||||
|
||||
fn eval(ast: &Ast) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, PartialEq)]
|
||||
struct NodeId(usize);
|
||||
impl fmt::Debug for NodeId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "NodeId({})", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Node {
|
||||
parent: Option<NodeId>,
|
||||
data: Option<Token>,
|
||||
left: Option<NodeId>,
|
||||
right: Option<NodeId>,
|
||||
}
|
||||
|
||||
impl Node {
|
||||
fn set_left_child(&mut self, id: Option<NodeId>) -> Option<NodeId> {
|
||||
let old = self.left;
|
||||
self.left = id;
|
||||
old
|
||||
}
|
||||
fn set_right_child(&mut self, id: Option<NodeId>) -> Option<NodeId> {
|
||||
let old = self.right;
|
||||
self.right = id;
|
||||
old
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Tree {
|
||||
nodes: Vec<Node>,
|
||||
root: NodeId,
|
||||
}
|
||||
|
||||
use std::fmt;
|
||||
impl fmt::Display for Tree {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fn print_node(f: &mut fmt::Formatter<'_>, tree: &Tree, id: NodeId) -> fmt::Result {
|
||||
//dbg!(id, tree.get_node(id));
|
||||
match tree.get_node(id).data {
|
||||
None => (),
|
||||
Some(Token::Num(n)) => write!(f, "{}", n)?,
|
||||
Some(Token::Add) => {
|
||||
print_node(f, tree, tree.get_node(id).left.unwrap())?;
|
||||
write!(f, "+",)?;
|
||||
print_node(f, tree, tree.get_node(id).right.unwrap())?;
|
||||
}
|
||||
Some(Token::Mul) => {
|
||||
print_node(f, tree, tree.get_node(id).left.unwrap())?;
|
||||
write!(f, "*",)?;
|
||||
print_node(f, tree, tree.get_node(id).right.unwrap())?;
|
||||
}
|
||||
Some(Token::Open) => {
|
||||
write!(f, "(",)?;
|
||||
}
|
||||
Some(Token::Close) => {
|
||||
write!(f, ")",)?;
|
||||
}
|
||||
Some(Token::Space) => {
|
||||
write!(f, " ",)?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
print_node(f, self, self.root)
|
||||
}
|
||||
}
|
||||
impl Default for Tree {
|
||||
fn default() -> Tree {
|
||||
Tree {
|
||||
nodes: vec![Node::default()],
|
||||
root: NodeId(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Tree {
|
||||
fn get_node(&self, id: NodeId) -> &Node {
|
||||
&self.nodes[id.0]
|
||||
}
|
||||
fn get_node_mut(&mut self, id: NodeId) -> &mut Node {
|
||||
&mut self.nodes[id.0]
|
||||
}
|
||||
fn add_node(&mut self, n: Node) -> NodeId {
|
||||
self.nodes.push(n);
|
||||
NodeId(self.nodes.len() - 1)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Parser {
|
||||
tree: Tree,
|
||||
cur: NodeId,
|
||||
debug_tokens: Vec<Token>,
|
||||
}
|
||||
|
||||
impl Parser {
|
||||
fn add_left_child_cur(&mut self, mut n: Node) -> NodeId {
|
||||
n.parent = Some(self.cur);
|
||||
let id = self.tree.add_node(n);
|
||||
self.cur_node_mut().left = Some(id);
|
||||
id
|
||||
}
|
||||
fn add_right_child_cur(&mut self, mut n: Node) -> NodeId {
|
||||
n.parent = Some(self.cur);
|
||||
let id = self.tree.add_node(n);
|
||||
self.cur_node_mut().right = Some(id);
|
||||
id
|
||||
}
|
||||
fn cur_node_mut(&mut self) -> &mut Node {
|
||||
self.tree.get_node_mut(self.cur)
|
||||
}
|
||||
|
||||
fn cur_node(&self) -> &Node {
|
||||
self.tree.get_node(self.cur)
|
||||
}
|
||||
fn set_cur_data(&mut self, t: &Token) {
|
||||
let cur = self.cur_node();
|
||||
let cur_id = self.cur;
|
||||
if cur.data.is_some() {
|
||||
match cur.right {
|
||||
Some(node) => {
|
||||
// Create a new node, stick it in `right` and reparent the previous node.
|
||||
let id = self.tree.add_node(Node {
|
||||
parent: Some(self.cur),
|
||||
..Node::default()
|
||||
});
|
||||
self.set_cur_node(id);
|
||||
self.tree.get_node_mut(cur_id).right = Some(id);
|
||||
self.cur_node_mut().left = Some(node);
|
||||
}
|
||||
None => {
|
||||
let id = self.add_right_child_cur(Node::default());
|
||||
self.set_cur_node(id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
self.cur_node_mut().data = Some(*t);
|
||||
}
|
||||
fn set_cur_node(&mut self, id: NodeId) {
|
||||
assert_ne!(Some(self.cur), self.cur_node().parent);
|
||||
self.cur = id;
|
||||
}
|
||||
fn set_cur_to_parent(&mut self) {
|
||||
match self.cur_node().parent {
|
||||
Some(parent) => self.set_cur_node(parent),
|
||||
None => {
|
||||
let id = self.tree.add_node(Node::default());
|
||||
self.cur_node_mut().parent = Some(id);
|
||||
let old_id = self.cur;
|
||||
self.tree.root = id;
|
||||
|
||||
self.set_cur_node(id);
|
||||
self.cur_node_mut().left = Some(old_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn add_token(&mut self, t: &Token) {
|
||||
//TODO(wathiede): we seem to be building the tree backwards so that walking the tree works
|
||||
// right-to-left instead of left-to-right.
|
||||
self.debug_tokens.push(*t);
|
||||
match t {
|
||||
Token::Num(_) => {
|
||||
self.set_cur_data(t);
|
||||
self.set_cur_to_parent();
|
||||
}
|
||||
Token::Add => {
|
||||
self.set_cur_data(t);
|
||||
let id = self.add_right_child_cur(Node::default());
|
||||
self.cur = id;
|
||||
}
|
||||
Token::Mul => {
|
||||
//dbg!(&self);
|
||||
self.set_cur_data(t);
|
||||
let id = self.add_right_child_cur(Node::default());
|
||||
self.cur = id;
|
||||
}
|
||||
Token::Open => {
|
||||
let id = self.add_left_child_cur(Node::default());
|
||||
self.cur = id;
|
||||
}
|
||||
Token::Close => self.set_cur_to_parent(),
|
||||
Token::Space => unreachable!("spaces should be filtered"),
|
||||
};
|
||||
}
|
||||
fn eval(&self) -> u32 {
|
||||
dbg!(&self.debug_tokens);
|
||||
dbg!(format!("{}", self.tree));
|
||||
fn eval_inner(tree: &Tree, id: NodeId) -> u32 {
|
||||
match tree.get_node(id).data {
|
||||
None => panic!("empty node"),
|
||||
Some(Token::Num(n)) => n,
|
||||
Some(Token::Add) => {
|
||||
let l = eval_inner(tree, tree.get_node(id).left.unwrap());
|
||||
let r = eval_inner(tree, tree.get_node(id).right.unwrap());
|
||||
dbg!(l, r);
|
||||
dbg!(l + r)
|
||||
}
|
||||
Some(Token::Mul) => {
|
||||
let l = eval_inner(tree, tree.get_node(id).left.unwrap());
|
||||
let r = eval_inner(tree, tree.get_node(id).right.unwrap());
|
||||
dbg!(l, r);
|
||||
dbg!(l * r)
|
||||
}
|
||||
Some(Token::Open) => panic!("("),
|
||||
Some(Token::Close) => panic!(")"),
|
||||
Some(Token::Space) => panic!(" "),
|
||||
}
|
||||
}
|
||||
eval_inner(&self.tree, self.tree.root)
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day18)]
|
||||
fn generator(input: &str) -> Vec<Vec<Token>> {
|
||||
input.split('\n').map(lex).collect()
|
||||
}
|
||||
|
||||
fn lex(input: &str) -> Vec<Token> {
|
||||
input
|
||||
.bytes()
|
||||
.map(|b| match b {
|
||||
b'(' => Token::Open,
|
||||
b')' => Token::Close,
|
||||
b'+' => Token::Add,
|
||||
b'*' => Token::Mul,
|
||||
b' ' => Token::Space,
|
||||
c @ b'0'..=b'9' => Token::Num((c - b'0') as u32),
|
||||
c => panic!(format!("unexpected char '{:?}'", c)),
|
||||
})
|
||||
// Ignore spaces
|
||||
.filter(|t| t != &Token::Space)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse(tokens: &[Token]) -> u32 {
|
||||
let mut p = Parser::default();
|
||||
dbg!(&p);
|
||||
tokens.into_iter().for_each(|t| p.add_token(t));
|
||||
p.eval()
|
||||
}
|
||||
|
||||
#[aoc(day18, part1)]
|
||||
fn solution1(tokens_list: &[Vec<Token>]) -> u32 {
|
||||
tokens_list.iter().map(|tokens| parse(tokens)).sum()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_lex() {
|
||||
let tokens = vec![
|
||||
Token::Num(2),
|
||||
Token::Mul,
|
||||
Token::Num(3),
|
||||
Token::Add,
|
||||
Token::Open,
|
||||
Token::Num(4),
|
||||
Token::Mul,
|
||||
Token::Num(5),
|
||||
Token::Close,
|
||||
];
|
||||
assert_eq!(lex("2 * 3 + (4 * 5)"), tokens);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
for (input, want) in vec![
|
||||
("1 + 2 * 3 + 4 * 5 + 6", 71),
|
||||
("2 * 3 + (4 * 5)", 26),
|
||||
("5 + (8 * 3 + 9 + 3 * 4 * 3)", 437),
|
||||
("5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4))", 12240),
|
||||
("((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2", 13632),
|
||||
] {
|
||||
dbg!(&input);
|
||||
assert_eq!(parse(&lex(input)), want, "{}", input);
|
||||
}
|
||||
}
|
||||
}
|
||||
245
2020/src/day19.rs
Normal file
245
2020/src/day19.rs
Normal file
@@ -0,0 +1,245 @@
|
||||
//! --- Day 19: Monster Messages ---
|
||||
//! You land in an airport surrounded by dense forest. As you walk to your high-speed train, the Elves at the Mythical Information Bureau contact you again. They think their satellite has collected an image of a sea monster! Unfortunately, the connection to the satellite is having problems, and many of the messages sent back from the satellite have been corrupted.
|
||||
//!
|
||||
//! They sent you a list of the rules valid messages should obey and a list of received messages they've collected so far (your puzzle input).
|
||||
//!
|
||||
//! The rules for valid messages (the top part of your puzzle input) are numbered and build upon each other. For example:
|
||||
//!
|
||||
//! 0: 1 2
|
||||
//! 1: "a"
|
||||
//! 2: 1 3 | 3 1
|
||||
//! 3: "b"
|
||||
//! Some rules, like 3: "b", simply match a single character (in this case, b).
|
||||
//!
|
||||
//! The remaining rules list the sub-rules that must be followed; for example, the rule 0: 1 2 means that to match rule 0, the text being checked must match rule 1, and the text after the part that matched rule 1 must then match rule 2.
|
||||
//!
|
||||
//! Some of the rules have multiple lists of sub-rules separated by a pipe (|). This means that at least one list of sub-rules must match. (The ones that match might be different each time the rule is encountered.) For example, the rule 2: 1 3 | 3 1 means that to match rule 2, the text being checked must match rule 1 followed by rule 3 or it must match rule 3 followed by rule 1.
|
||||
//!
|
||||
//! Fortunately, there are no loops in the rules, so the list of possible matches will be finite. Since rule 1 matches a and rule 3 matches b, rule 2 matches either ab or ba. Therefore, rule 0 matches aab or aba.
|
||||
//!
|
||||
//! Here's a more interesting example:
|
||||
//!
|
||||
//! 0: 4 1 5
|
||||
//! 1: 2 3 | 3 2
|
||||
//! 2: 4 4 | 5 5
|
||||
//! 3: 4 5 | 5 4
|
||||
//! 4: "a"
|
||||
//! 5: "b"
|
||||
//! Here, because rule 4 matches a and rule 5 matches b, rule 2 matches two letters that are the same (aa or bb), and rule 3 matches two letters that are different (ab or ba).
|
||||
//!
|
||||
//! Since rule 1 matches rules 2 and 3 once each in either order, it must match two pairs of letters, one pair with matching letters and one pair with different letters. This leaves eight possibilities: aaab, aaba, bbab, bbba, abaa, abbb, baaa, or babb.
|
||||
//!
|
||||
//! Rule 0, therefore, matches a (rule 4), then any of the eight options from rule 1, then b (rule 5): aaaabb, aaabab, abbabb, abbbab, aabaab, aabbbb, abaaab, or ababbb.
|
||||
//!
|
||||
//! The received messages (the bottom part of your puzzle input) need to be checked against the rules so you can determine which are valid and which are corrupted. Including the rules and the messages together, this might look like:
|
||||
//!
|
||||
//! 0: 4 1 5
|
||||
//! 1: 2 3 | 3 2
|
||||
//! 2: 4 4 | 5 5
|
||||
//! 3: 4 5 | 5 4
|
||||
//! 4: "a"
|
||||
//! 5: "b"
|
||||
//!
|
||||
//! ababbb
|
||||
//! bababa
|
||||
//! abbbab
|
||||
//! aaabbb
|
||||
//! aaaabbb
|
||||
//! Your goal is to determine the number of messages that completely match rule 0. In the above example, ababbb and abbbab match, but bababa, aaabbb, and aaaabbb do not, producing the answer 2. The whole message must match all of rule 0; there can't be extra unmatched characters in the message. (For example, aaaabbb might appear to match rule 0 above, but it has an extra unmatched b on the end.)
|
||||
//!
|
||||
//! How many messages completely match rule 0?
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
use regex::Regex;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Input {
|
||||
rules: Regex,
|
||||
messages: Vec<String>,
|
||||
}
|
||||
|
||||
impl PartialEq for Input {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.rules.as_str() == other.rules.as_str() && self.messages == other.messages
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||
enum Entry {
|
||||
Rule(usize),
|
||||
Char(String),
|
||||
}
|
||||
impl fmt::Debug for Entry {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Entry::Rule(n) => write!(f, "Entry({})", n)?,
|
||||
Entry::Char(c) => write!(f, r#"Entry("{}")"#, c)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
struct Resolver {
|
||||
rule_map: HashMap<usize, Vec<Vec<Entry>>>,
|
||||
resolved: HashMap<Entry, String>,
|
||||
}
|
||||
|
||||
impl Resolver {
|
||||
fn resolve(&mut self, e: &Entry) -> String {
|
||||
if let Some(v) = self.resolved.get(e) {
|
||||
return v.to_string();
|
||||
}
|
||||
|
||||
match e {
|
||||
Entry::Char(s) => {
|
||||
self.resolved.insert(e.clone(), s.to_string());
|
||||
s.to_string()
|
||||
}
|
||||
Entry::Rule(n) => {
|
||||
let subrules: Vec<String> = self.rule_map[n]
|
||||
// TODO(wathiede): clone here seems inefficient, but it made the borrow checker
|
||||
// happy given the &mut recursive call to self.resolve in the map closure.
|
||||
.clone()
|
||||
.iter()
|
||||
.map(|rule| {
|
||||
let letters: Vec<_> = rule.iter().map(|e| self.resolve(e)).collect();
|
||||
letters.join("")
|
||||
})
|
||||
.collect();
|
||||
let s = subrules.join("|");
|
||||
|
||||
if subrules.len() > 1 {
|
||||
// More than one rule,
|
||||
return format!("({})", s);
|
||||
}
|
||||
s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_rulemap(rule_map: HashMap<usize, Vec<Vec<Entry>>>) -> Regex {
|
||||
let mut r = Resolver {
|
||||
rule_map,
|
||||
resolved: HashMap::new(),
|
||||
};
|
||||
let rule_zero = r.rule_map[&0][0].clone();
|
||||
let re = rule_zero
|
||||
.iter()
|
||||
.fold("".to_string(), |acc, e| format!("{}{}", acc, r.resolve(e)));
|
||||
|
||||
Regex::new(&format!(r"^{}$", re)).unwrap()
|
||||
}
|
||||
|
||||
fn make_rules(lines: Vec<String>) -> Regex {
|
||||
let mut rules = HashMap::new();
|
||||
|
||||
lines.iter().for_each(|l| {
|
||||
let idx = l.find(':').expect("missing ':'");
|
||||
let k: usize = l[..idx].parse().expect("failed to parse number");
|
||||
|
||||
let sub: Vec<Vec<Entry>> = l[idx + 2..]
|
||||
.split(" | ")
|
||||
.map(|sub| {
|
||||
sub.split(' ')
|
||||
.map(|p| match p.parse() {
|
||||
Ok(n) => Entry::Rule(n),
|
||||
Err(_) => Entry::Char(
|
||||
p.strip_prefix("\"")
|
||||
.unwrap()
|
||||
.strip_suffix("\"")
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
),
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
rules.insert(k, sub);
|
||||
});
|
||||
expand_rulemap(rules)
|
||||
}
|
||||
|
||||
#[aoc_generator(day19)]
|
||||
fn generator(input: &str) -> Input {
|
||||
let mut it = input.split("\n\n");
|
||||
let rules = make_rules(
|
||||
it.next()
|
||||
.unwrap()
|
||||
.split('\n')
|
||||
.map(|s| s.trim().to_string())
|
||||
.collect(),
|
||||
);
|
||||
|
||||
let messages = it
|
||||
.next()
|
||||
.unwrap()
|
||||
.split('\n')
|
||||
.map(|s| s.trim().to_string())
|
||||
.collect();
|
||||
Input { rules, messages }
|
||||
}
|
||||
|
||||
#[aoc(day19, part1)]
|
||||
fn solution1(input: &Input) -> usize {
|
||||
input
|
||||
.messages
|
||||
.iter()
|
||||
.filter(|msg| input.rules.is_match(msg))
|
||||
.count()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const INPUT: &'static str = r#"0: 4 1 5
|
||||
1: 2 3 | 3 2
|
||||
2: 4 4 | 5 5
|
||||
3: 4 5 | 5 4
|
||||
4: "a"
|
||||
5: "b"
|
||||
|
||||
ababbb
|
||||
bababa
|
||||
abbbab
|
||||
aaabbb
|
||||
aaaabbb"#;
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&generator(INPUT)), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse() {
|
||||
assert_eq!(
|
||||
generator(INPUT),
|
||||
Input {
|
||||
rules: Regex::new("^a((aa|bb)(ab|ba)|(ab|ba)(aa|bb))b$").unwrap(),
|
||||
messages: vec!["ababbb", "bababa", "abbbab", "aaabbb", "aaaabbb",]
|
||||
.into_iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
}
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn expand() {
|
||||
use Entry::*;
|
||||
let r: HashMap<usize, Vec<Vec<Entry>>> = vec![
|
||||
vec![vec![Rule(1)]],
|
||||
vec![vec![Rule(2), Rule(2)], vec![Rule(3), Rule(3)]],
|
||||
vec![vec![Char("a".to_string())]],
|
||||
vec![vec![Char("b".to_string())]],
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.collect();
|
||||
assert_eq!(
|
||||
expand_rulemap(r).as_str(),
|
||||
Regex::new("^(aa|bb)$").unwrap().as_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
365
2020/src/day4.rs
Normal file
365
2020/src/day4.rs
Normal file
@@ -0,0 +1,365 @@
|
||||
//! --- Day 4: Passport Processing ---
|
||||
//! You arrive at the airport only to realize that you grabbed your North Pole Credentials instead of your passport. While these documents are extremely similar, North Pole Credentials aren't issued by a country and therefore aren't actually valid documentation for travel in most of the world.
|
||||
//!
|
||||
//! It seems like you're not the only one having problems, though; a very long line has formed for the automatic passport scanners, and the delay could upset your travel itinerary.
|
||||
//!
|
||||
//! Due to some questionable network security, you realize you might be able to solve both of these problems at the same time.
|
||||
//!
|
||||
//! The automatic passport scanners are slow because they're having trouble detecting which passports have all required fields. The expected fields are as follows:
|
||||
//!
|
||||
//! byr (Birth Year)
|
||||
//! iyr (Issue Year)
|
||||
//! eyr (Expiration Year)
|
||||
//! hgt (Height)
|
||||
//! hcl (Hair Color)
|
||||
//! ecl (Eye Color)
|
||||
//! pid (Passport ID)
|
||||
//! cid (Country ID)
|
||||
//! Passport data is validated in batch files (your puzzle input). Each passport is represented as a sequence of key:value pairs separated by spaces or newlines. Passports are separated by blank lines.
|
||||
//!
|
||||
//! Here is an example batch file containing four passports:
|
||||
//!
|
||||
//! ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
|
||||
//! byr:1937 iyr:2017 cid:147 hgt:183cm
|
||||
//!
|
||||
//! iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
|
||||
//! hcl:#cfa07d byr:1929
|
||||
//!
|
||||
//! hcl:#ae17e1 iyr:2013
|
||||
//! eyr:2024
|
||||
//! ecl:brn pid:760753108 byr:1931
|
||||
//! hgt:179cm
|
||||
//!
|
||||
//! hcl:#cfa07d eyr:2025 pid:166559648
|
||||
//! iyr:2011 ecl:brn hgt:59in
|
||||
//! The first passport is valid - all eight fields are present. The second passport is invalid - it is missing hgt (the Height field).
|
||||
//!
|
||||
//! The third passport is interesting; the only missing field is cid, so it looks like data from North Pole Credentials, not a passport at all! Surely, nobody would mind if you made the system temporarily ignore missing cid fields. Treat this "passport" as valid.
|
||||
//!
|
||||
//! The fourth passport is missing two fields, cid and byr. Missing cid is fine, but missing any other field is not, so this passport is invalid.
|
||||
//!
|
||||
//! According to the above rules, your improved system would report 2 valid passports.
|
||||
//!
|
||||
//! Count the number of valid passports - those that have all required fields. Treat cid as optional. In your batch file, how many passports are valid?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! The line is moving more quickly now, but you overhear airport security talking about how passports with invalid data are getting through. Better add some data validation, quick!
|
||||
//!
|
||||
//! You can continue to ignore the cid field, but each other field has strict rules about what values are valid for automatic validation:
|
||||
//!
|
||||
//! byr (Birth Year) - four digits; at least 1920 and at most 2002.
|
||||
//! iyr (Issue Year) - four digits; at least 2010 and at most 2020.
|
||||
//! eyr (Expiration Year) - four digits; at least 2020 and at most 2030.
|
||||
//! hgt (Height) - a number followed by either cm or in:
|
||||
//! If cm, the number must be at least 150 and at most 193.
|
||||
//! If in, the number must be at least 59 and at most 76.
|
||||
//! hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f.
|
||||
//! ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth.
|
||||
//! pid (Passport ID) - a nine-digit number, including leading zeroes.
|
||||
//! cid (Country ID) - ignored, missing or not.
|
||||
//! Your job is to count the passports where all required fields are both present and valid according to the above rules. Here are some example values:
|
||||
//!
|
||||
//! byr valid: 2002
|
||||
//! byr invalid: 2003
|
||||
//!
|
||||
//! hgt valid: 60in
|
||||
//! hgt valid: 190cm
|
||||
//! hgt invalid: 190in
|
||||
//! hgt invalid: 190
|
||||
//!
|
||||
//! hcl valid: #123abc
|
||||
//! hcl invalid: #123abz
|
||||
//! hcl invalid: 123abc
|
||||
//!
|
||||
//! ecl valid: brn
|
||||
//! ecl invalid: wat
|
||||
//!
|
||||
//! pid valid: 000000001
|
||||
//! pid invalid: 0123456789
|
||||
//! Here are some invalid passports:
|
||||
//!
|
||||
//! eyr:1972 cid:100
|
||||
//! hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926
|
||||
//!
|
||||
//! iyr:2019
|
||||
//! hcl:#602927 eyr:1967 hgt:170cm
|
||||
//! ecl:grn pid:012533040 byr:1946
|
||||
//!
|
||||
//! hcl:dab227 iyr:2012
|
||||
//! ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277
|
||||
//!
|
||||
//! hgt:59cm ecl:zzz
|
||||
//! eyr:2038 hcl:74454a iyr:2023
|
||||
//! pid:3556412378 byr:2007
|
||||
//! Here are some valid passports:
|
||||
//!
|
||||
//! pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
|
||||
//! hcl:#623a2f
|
||||
//!
|
||||
//! eyr:2029 ecl:blu cid:129 byr:1989
|
||||
//! iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm
|
||||
//!
|
||||
//! hcl:#888785
|
||||
//! hgt:164cm byr:2001 iyr:2015 cid:88
|
||||
//! pid:545766238 ecl:hzl
|
||||
//! eyr:2022
|
||||
//!
|
||||
//! iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719
|
||||
//! Count the number of valid passports - those that have all required fields and valid values. Continue to treat cid as optional. In your batch file, how many passports are valid?
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
struct Passport {
|
||||
// Birth Year
|
||||
byr: Option<String>,
|
||||
// Issue Year
|
||||
iyr: Option<String>,
|
||||
// Expiration Year
|
||||
eyr: Option<String>,
|
||||
// Height
|
||||
hgt: Option<String>,
|
||||
// Hair Color
|
||||
hcl: Option<String>,
|
||||
// Eye Color
|
||||
ecl: Option<String>,
|
||||
// Passport ID
|
||||
pid: Option<String>,
|
||||
// Country ID
|
||||
cid: Option<String>,
|
||||
}
|
||||
|
||||
fn valid_num(s: &Option<String>, min: u32, max: u32) -> bool {
|
||||
match s {
|
||||
Some(yr) => match yr.parse() {
|
||||
Ok(n) => min <= n && n <= max,
|
||||
Err(_) => false,
|
||||
},
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn valid_height(s: &Option<String>) -> bool {
|
||||
if let Some(h) = s {
|
||||
if h.ends_with("cm") {
|
||||
return valid_num(&Some(h[..h.len() - 2].to_string()), 150, 193);
|
||||
};
|
||||
if h.ends_with("in") {
|
||||
return valid_num(&Some(h[..h.len() - 2].to_string()), 59, 76);
|
||||
};
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn valid_hair_color(s: &Option<String>) -> bool {
|
||||
if let Some(h) = s {
|
||||
let chars: Vec<_> = h.chars().collect();
|
||||
if chars.len() != 7 {
|
||||
return false;
|
||||
}
|
||||
for c in &chars[1..] {
|
||||
if &'0' <= c && c <= &'f' {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn valid_eye_color(s: &Option<String>) -> bool {
|
||||
if let Some(c) = s {
|
||||
return match c.as_str() {
|
||||
"amb" | "blu" | "brn" | "gry" | "grn" | "hzl" | "oth" => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn valid_passport_id(s: &Option<String>) -> bool {
|
||||
if let Some(pid) = s {
|
||||
if pid.len() != 9 {
|
||||
return false;
|
||||
}
|
||||
for c in pid.chars() {
|
||||
if '0' <= c && c <= '9' {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
impl Passport {
|
||||
fn is_valid_part1(&self) -> bool {
|
||||
self.byr.is_some()
|
||||
&& self.iyr.is_some()
|
||||
&& self.eyr.is_some()
|
||||
&& self.hgt.is_some()
|
||||
&& self.hcl.is_some()
|
||||
&& self.ecl.is_some()
|
||||
&& self.pid.is_some()
|
||||
}
|
||||
|
||||
fn is_valid_part2(&self) -> bool {
|
||||
valid_num(&self.byr, 1920, 2002)
|
||||
&& valid_num(&self.iyr, 2010, 2020)
|
||||
&& valid_num(&self.eyr, 2020, 2030)
|
||||
&& valid_height(&self.hgt)
|
||||
&& valid_hair_color(&self.hcl)
|
||||
&& valid_eye_color(&self.ecl)
|
||||
&& valid_passport_id(&self.pid)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Passport {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(input: &str) -> Result<Passport, ()> {
|
||||
let mut p = Passport::default();
|
||||
input
|
||||
.replace('\n', " ")
|
||||
.split(' ')
|
||||
.filter(|p| !p.is_empty())
|
||||
.for_each(|part| {
|
||||
let (k, v) = part.split_at(part.find(":").unwrap());
|
||||
match k {
|
||||
"byr" => p.byr = Some(v[1..].to_string()),
|
||||
"iyr" => p.iyr = Some(v[1..].to_string()),
|
||||
"eyr" => p.eyr = Some(v[1..].to_string()),
|
||||
"hgt" => p.hgt = Some(v[1..].to_string()),
|
||||
"hcl" => p.hcl = Some(v[1..].to_string()),
|
||||
"ecl" => p.ecl = Some(v[1..].to_string()),
|
||||
"pid" => p.pid = Some(v[1..].to_string()),
|
||||
"cid" => p.cid = Some(v[1..].to_string()),
|
||||
s => panic!(format!("unknown key: '{}'", s)),
|
||||
};
|
||||
});
|
||||
Ok(p)
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day4)]
|
||||
fn parse(input: &str) -> Vec<Passport> {
|
||||
input.split("\n\n").filter_map(|s| s.parse().ok()).collect()
|
||||
}
|
||||
|
||||
#[aoc(day4, part1)]
|
||||
fn solution_part1(passports: &[Passport]) -> usize {
|
||||
passports.iter().filter(|p| p.is_valid_part1()).count()
|
||||
}
|
||||
|
||||
#[aoc(day4, part2)]
|
||||
fn solution_part2(passports: &[Passport]) -> usize {
|
||||
passports.iter().filter(|p| p.is_valid_part2()).count()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &'static str = r##"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
|
||||
byr:1937 iyr:2017 cid:147 hgt:183cm
|
||||
|
||||
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
|
||||
hcl:#cfa07d byr:1929
|
||||
|
||||
hcl:#ae17e1 iyr:2013
|
||||
eyr:2024
|
||||
ecl:brn pid:760753108 byr:1931
|
||||
hgt:179cm
|
||||
|
||||
hcl:#cfa07d eyr:2025 pid:166559648
|
||||
iyr:2011 ecl:brn hgt:59in
|
||||
"##;
|
||||
|
||||
#[test]
|
||||
fn parse_passports() {
|
||||
assert_eq!(
|
||||
parse(INPUT),
|
||||
vec![
|
||||
Passport {
|
||||
ecl: Some("gry".to_string()),
|
||||
pid: Some("860033327".to_string()),
|
||||
eyr: Some("2020".to_string()),
|
||||
hcl: Some("#fffffd".to_string()),
|
||||
byr: Some("1937".to_string()),
|
||||
iyr: Some("2017".to_string()),
|
||||
cid: Some("147".to_string()),
|
||||
hgt: Some("183cm".to_string()),
|
||||
},
|
||||
Passport {
|
||||
iyr: Some("2013".to_string()),
|
||||
ecl: Some("amb".to_string()),
|
||||
cid: Some("350".to_string()),
|
||||
eyr: Some("2023".to_string()),
|
||||
pid: Some("028048884".to_string()),
|
||||
hcl: Some("#cfa07d".to_string()),
|
||||
byr: Some("1929".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
Passport {
|
||||
hcl: Some("#ae17e1".to_string()),
|
||||
iyr: Some("2013".to_string()),
|
||||
eyr: Some("2024".to_string()),
|
||||
ecl: Some("brn".to_string()),
|
||||
pid: Some("760753108".to_string()),
|
||||
byr: Some("1931".to_string()),
|
||||
hgt: Some("179cm".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
Passport {
|
||||
hcl: Some("#cfa07d".to_string()),
|
||||
eyr: Some("2025".to_string()),
|
||||
pid: Some("166559648".to_string()),
|
||||
iyr: Some("2011".to_string()),
|
||||
ecl: Some("brn".to_string()),
|
||||
hgt: Some("59in".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_part2() {
|
||||
let input = r##"eyr:1972 cid:100
|
||||
hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926
|
||||
|
||||
iyr:2019
|
||||
hcl:#602927 eyr:1967 hgt:170cm
|
||||
ecl:grn pid:012533040 byr:1946
|
||||
|
||||
hcl:dab227 iyr:2012
|
||||
ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277
|
||||
|
||||
hgt:59cm ecl:zzz
|
||||
eyr:2038 hcl:74454a iyr:2023
|
||||
pid:3556412378 byr:2007
|
||||
"##;
|
||||
assert_eq!(solution_part2(&parse(input)), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_part2() {
|
||||
let input = r##"pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
|
||||
hcl:#623a2f
|
||||
|
||||
eyr:2029 ecl:blu cid:129 byr:1989
|
||||
iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm
|
||||
|
||||
hcl:#888785
|
||||
hgt:164cm byr:2001 iyr:2015 cid:88
|
||||
pid:545766238 ecl:hzl
|
||||
eyr:2022
|
||||
|
||||
iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719
|
||||
"##;
|
||||
assert_eq!(solution_part2(&parse(input)), 4);
|
||||
}
|
||||
}
|
||||
166
2020/src/day5.rs
Normal file
166
2020/src/day5.rs
Normal file
@@ -0,0 +1,166 @@
|
||||
//! --- Day 5: Binary Boarding ---
|
||||
//! You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control.
|
||||
//!
|
||||
//! You write a quick program to use your phone's camera to scan all of the nearby boarding passes (your puzzle input); perhaps you can find your seat through process of elimination.
|
||||
//!
|
||||
//! Instead of zones or groups, this airline uses binary space partitioning to seat people. A seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means "left", and R means "right".
|
||||
//!
|
||||
//! The first 7 characters will either be F or B; these specify exactly one of the 128 rows on the plane (numbered 0 through 127). Each letter tells you which half of a region the given seat is in. Start with the whole list of rows; the first letter indicates whether the seat is in the front (0 through 63) or the back (64 through 127). The next letter indicates which half of that region the seat is in, and so on until you're left with exactly one row.
|
||||
//!
|
||||
//! For example, consider just the first seven characters of FBFBBFFRLR:
|
||||
//!
|
||||
//! Start by considering the whole range, rows 0 through 127.
|
||||
//! F means to take the lower half, keeping rows 0 through 63.
|
||||
//! B means to take the upper half, keeping rows 32 through 63.
|
||||
//! F means to take the lower half, keeping rows 32 through 47.
|
||||
//! B means to take the upper half, keeping rows 40 through 47.
|
||||
//! B keeps rows 44 through 47.
|
||||
//! F keeps rows 44 through 45.
|
||||
//! The final F keeps the lower of the two, row 44.
|
||||
//! The last three characters will be either L or R; these specify exactly one of the 8 columns of seats on the plane (numbered 0 through 7). The same process as above proceeds again, this time with only three steps. L means to keep the lower half, while R means to keep the upper half.
|
||||
//!
|
||||
//! For example, consider just the last 3 characters of FBFBBFFRLR:
|
||||
//!
|
||||
//! Start by considering the whole range, columns 0 through 7.
|
||||
//! R means to take the upper half, keeping columns 4 through 7.
|
||||
//! L means to take the lower half, keeping columns 4 through 5.
|
||||
//! The final R keeps the upper of the two, column 5.
|
||||
//! So, decoding FBFBBFFRLR reveals that it is the seat at row 44, column 5.
|
||||
//!
|
||||
//! Every seat also has a unique seat ID: multiply the row by 8, then add the column. In this example, the seat has ID 44 * 8 + 5 = 357.
|
||||
//!
|
||||
//! Here are some other boarding passes:
|
||||
//!
|
||||
//! BFFFBBFRRR: row 70, column 7, seat ID 567.
|
||||
//! FFFBBBFRRR: row 14, column 7, seat ID 119.
|
||||
//! BBFFBBFRLL: row 102, column 4, seat ID 820.
|
||||
//! As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! Ding! The "fasten seat belt" signs have turned on. Time to find your seat.
|
||||
//!
|
||||
//! It's a completely full flight, so your seat should be the only missing boarding pass in your list. However, there's a catch: some of the seats at the very front and back of the plane don't exist on this aircraft, so they'll be missing from your list as well.
|
||||
//!
|
||||
//! Your seat wasn't at the very front or back, though; the seats with IDs +1 and -1 from yours will be in your list.
|
||||
//!
|
||||
//! What is the ID of your seat?
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct Seat {
|
||||
row: u32,
|
||||
column: u32,
|
||||
}
|
||||
|
||||
impl Seat {
|
||||
fn id(&self) -> u32 {
|
||||
self.row * 8 + self.column
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Seat {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut r_start = 0;
|
||||
let mut r_size = 128 / 2;
|
||||
let mut c_start = 0;
|
||||
let mut c_size = 8 / 2;
|
||||
s.chars().for_each(|c| match c {
|
||||
'F' => r_size /= 2,
|
||||
'B' => {
|
||||
r_start += r_size;
|
||||
r_size /= 2;
|
||||
}
|
||||
'L' => c_size /= 2,
|
||||
'R' => {
|
||||
c_start += c_size;
|
||||
c_size /= 2;
|
||||
}
|
||||
c => panic!(format!("unexpected character '{}'", c)),
|
||||
});
|
||||
Ok(Seat {
|
||||
row: r_start,
|
||||
column: c_start,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day5, part1, wathiede)]
|
||||
#[aoc_generator(day5, part2, wathiede)]
|
||||
fn parse(input: &str) -> Vec<Seat> {
|
||||
input
|
||||
.split('\n')
|
||||
.map(str::parse)
|
||||
.filter_map(Result::ok)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[aoc(day5, part1, wathiede)]
|
||||
fn solution1(seats: &[Seat]) -> u32 {
|
||||
seats.iter().map(|s| s.id()).max().unwrap()
|
||||
}
|
||||
|
||||
#[aoc(day5, part1, glenng)]
|
||||
fn solution1_glenng(input: &str) -> u32 {
|
||||
input
|
||||
.split('\n')
|
||||
.map(|s| {
|
||||
s.chars().fold(0, |s, c| match c {
|
||||
'F' | 'L' => s << 1,
|
||||
'B' | 'R' => s << 1 | 1,
|
||||
_ => panic!(format!("unexpected character '{}'", c)),
|
||||
})
|
||||
})
|
||||
.map(|s| {
|
||||
let r = s >> 3;
|
||||
let c = s & 0b111;
|
||||
r * 8 + c
|
||||
})
|
||||
.max()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[aoc(day5, part2, wathiede)]
|
||||
fn solution2(seats: &[Seat]) -> u32 {
|
||||
let mut seat_ids: Vec<_> = seats.iter().map(|s| s.id()).collect();
|
||||
seat_ids.sort();
|
||||
let mut last_id = seat_ids[0];
|
||||
for id in &seat_ids[1..] {
|
||||
if id - last_id != 1 {
|
||||
return id - 1;
|
||||
}
|
||||
last_id = *id;
|
||||
}
|
||||
panic!();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &'static str = "BFFFBBFRRR\nFFFBBBFRRR\nBBFFBBFRLL";
|
||||
static WANT: &'static [Seat] = &[
|
||||
Seat { row: 70, column: 7 },
|
||||
Seat { row: 14, column: 7 },
|
||||
Seat {
|
||||
row: 102,
|
||||
column: 4,
|
||||
},
|
||||
];
|
||||
|
||||
#[test]
|
||||
fn parse_seats() {
|
||||
assert_eq!(parse(INPUT), WANT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn id() {
|
||||
assert_eq!(
|
||||
WANT.iter().map(|s| s.id()).collect::<Vec<u32>>(),
|
||||
vec![567, 119, 820]
|
||||
);
|
||||
}
|
||||
}
|
||||
161
2020/src/day6.rs
Normal file
161
2020/src/day6.rs
Normal file
@@ -0,0 +1,161 @@
|
||||
//! --- Day 6: Custom Customs ---
|
||||
//! As your flight approaches the regional airport where you'll switch to a much larger plane, customs declaration forms are distributed to the passengers.
|
||||
//!
|
||||
//! The form asks a series of 26 yes-or-no questions marked a through z. All you need to do is identify the questions for which anyone in your group answers "yes". Since your group is just you, this doesn't take very long.
|
||||
//!
|
||||
//! However, the person sitting next to you seems to be experiencing a language barrier and asks if you can help. For each of the people in their group, you write down the questions for which they answer "yes", one per line. For example:
|
||||
//!
|
||||
//! abcx
|
||||
//! abcy
|
||||
//! abcz
|
||||
//! In this group, there are 6 questions to which anyone answered "yes": a, b, c, x, y, and z. (Duplicate answers to the same question don't count extra; each question counts at most once.)
|
||||
//!
|
||||
//! Another group asks for your help, then another, and eventually you've collected answers from every group on the plane (your puzzle input). Each group's answers are separated by a blank line, and within each group, each person's answers are on a single line. For example:
|
||||
//!
|
||||
//! abc
|
||||
//!
|
||||
//! a
|
||||
//! b
|
||||
//! c
|
||||
//!
|
||||
//! ab
|
||||
//! ac
|
||||
//!
|
||||
//! a
|
||||
//! a
|
||||
//! a
|
||||
//! a
|
||||
//!
|
||||
//! b
|
||||
//! This list represents answers from five groups:
|
||||
//!
|
||||
//! The first group contains one person who answered "yes" to 3 questions: a, b, and c.
|
||||
//! The second group contains three people; combined, they answered "yes" to 3 questions: a, b, and c.
|
||||
//! The third group contains two people; combined, they answered "yes" to 3 questions: a, b, and c.
|
||||
//! The fourth group contains four people; combined, they answered "yes" to only 1 question, a.
|
||||
//! The last group contains one person who answered "yes" to only 1 question, b.
|
||||
//! In this example, the sum of these counts is 3 + 3 + 3 + 1 + 1 = 11.
|
||||
//!
|
||||
//! For each group, count the number of questions to which anyone answered "yes". What is the sum of those counts?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! As you finish the last group's customs declaration, you notice that you misread one word in the instructions:
|
||||
//!
|
||||
//! You don't need to identify the questions to which anyone answered "yes"; you need to identify the questions to which everyone answered "yes"!
|
||||
//!
|
||||
//! Using the same example as above:
|
||||
//!
|
||||
//! abc
|
||||
//!
|
||||
//! a
|
||||
//! b
|
||||
//! c
|
||||
//!
|
||||
//! ab
|
||||
//! ac
|
||||
//!
|
||||
//! a
|
||||
//! a
|
||||
//! a
|
||||
//! a
|
||||
//!
|
||||
//! b
|
||||
//! This list represents answers from five groups:
|
||||
//!
|
||||
//! In the first group, everyone (all 1 person) answered "yes" to 3 questions: a, b, and c.
|
||||
//! In the second group, there is no question to which everyone answered "yes".
|
||||
//! In the third group, everyone answered yes to only 1 question, a. Since some people did not answer "yes" to b or c, they don't count.
|
||||
//! In the fourth group, everyone answered yes to only 1 question, a.
|
||||
//! In the fifth group, everyone (all 1 person) answered "yes" to 1 question, b.
|
||||
//! In this example, the sum of these counts is 3 + 0 + 1 + 1 + 1 = 6.
|
||||
//!
|
||||
//! For each group, count the number of questions to which everyone answered "yes". What is the sum of those counts?
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use aoc_runner_derive::aoc;
|
||||
|
||||
#[aoc(day6, part1)]
|
||||
fn solution1(input: &str) -> usize {
|
||||
input
|
||||
.split("\n\n")
|
||||
.map(|group| group.chars().filter(|c| c != &'\n').collect::<HashSet<_>>())
|
||||
.map(|set| set.len())
|
||||
.sum()
|
||||
}
|
||||
|
||||
#[aoc(day6, part2)]
|
||||
fn solution2(input: &str) -> usize {
|
||||
input
|
||||
.split("\n\n")
|
||||
.map(|group| {
|
||||
let sets = group
|
||||
.split('\n')
|
||||
.map(|p| p.chars().collect::<HashSet<_>>())
|
||||
.collect::<Vec<_>>();
|
||||
// Find letters common to all sets int this group.
|
||||
sets.iter().fold(sets.first().unwrap().clone(), |acc, s| {
|
||||
acc.intersection(s).cloned().collect()
|
||||
})
|
||||
})
|
||||
.map(|set| set.len())
|
||||
.sum()
|
||||
}
|
||||
|
||||
#[aoc(day6, part2, faster)]
|
||||
fn solution2_faster(input: &str) -> usize {
|
||||
input
|
||||
.split("\n\n")
|
||||
.filter_map(|group| {
|
||||
group.split('\n').fold(None, |acc: Option<HashSet<_>>, p| {
|
||||
match acc {
|
||||
None => {
|
||||
// Add all the letters for the first set.
|
||||
Some(p.chars().collect())
|
||||
}
|
||||
Some(acc) => {
|
||||
// Remove from acc any letters not in p.
|
||||
let tmp = Some(
|
||||
p.chars()
|
||||
.filter(|c| acc.contains(c))
|
||||
.collect::<HashSet<_>>(),
|
||||
);
|
||||
tmp
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
.map(|set| set.len())
|
||||
.sum()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT: &'static str = r#"abc
|
||||
|
||||
a
|
||||
b
|
||||
c
|
||||
|
||||
ab
|
||||
ac
|
||||
|
||||
a
|
||||
a
|
||||
a
|
||||
a
|
||||
|
||||
b"#;
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(INPUT), 11);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(INPUT), 6);
|
||||
}
|
||||
}
|
||||
204
2020/src/day7.rs
Normal file
204
2020/src/day7.rs
Normal file
@@ -0,0 +1,204 @@
|
||||
//! --- Day 7: Handy Haversacks ---
|
||||
//! You land at the regional airport in time for your next flight. In fact, it looks like you'll even have time to grab some food: all flights are currently delayed due to issues in luggage processing.
|
||||
//!
|
||||
//! Due to recent aviation regulations, many rules (your puzzle input) are being enforced about bags and their contents; bags must be color-coded and must contain specific quantities of other color-coded bags. Apparently, nobody responsible for these regulations considered how long they would take to enforce!
|
||||
//!
|
||||
//! For example, consider the following rules:
|
||||
//!
|
||||
//! light red bags contain 1 bright white bag, 2 muted yellow bags.
|
||||
//! dark orange bags contain 3 bright white bags, 4 muted yellow bags.
|
||||
//! bright white bags contain 1 shiny gold bag.
|
||||
//! muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
|
||||
//! shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
|
||||
//! dark olive bags contain 3 faded blue bags, 4 dotted black bags.
|
||||
//! vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
|
||||
//! faded blue bags contain no other bags.
|
||||
//! dotted black bags contain no other bags.
|
||||
//! These rules specify the required contents for 9 bag types. In this example, every faded blue bag is empty, every vibrant plum bag contains 11 bags (5 faded blue and 6 dotted black), and so on.
|
||||
//!
|
||||
//! You have a shiny gold bag. If you wanted to carry it in at least one other bag, how many different bag colors would be valid for the outermost bag? (In other words: how many colors can, eventually, contain at least one shiny gold bag?)
|
||||
//!
|
||||
//! In the above rules, the following options would be available to you:
|
||||
//!
|
||||
//! A bright white bag, which can hold your shiny gold bag directly.
|
||||
//! A muted yellow bag, which can hold your shiny gold bag directly, plus some other bags.
|
||||
//! A dark orange bag, which can hold bright white and muted yellow bags, either of which could then hold your shiny gold bag.
|
||||
//! A light red bag, which can hold bright white and muted yellow bags, either of which could then hold your shiny gold bag.
|
||||
//! So, in this example, the number of bag colors that can eventually contain at least one shiny gold bag is 4.
|
||||
//!
|
||||
//! How many bag colors can eventually contain at least one shiny gold bag? (The list of rules is quite long; make sure you get all of it.)
|
||||
//!
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! It's getting pretty expensive to fly these days - not because of ticket prices, but because of the ridiculous number of bags you need to buy!
|
||||
//!
|
||||
//! Consider again your shiny gold bag and the rules from the above example:
|
||||
//!
|
||||
//! faded blue bags contain 0 other bags.
|
||||
//! dotted black bags contain 0 other bags.
|
||||
//! vibrant plum bags contain 11 other bags: 5 faded blue bags and 6 dotted black bags.
|
||||
//! dark olive bags contain 7 other bags: 3 faded blue bags and 4 dotted black bags.
|
||||
//! So, a single shiny gold bag must contain 1 dark olive bag (and the 7 bags within it) plus 2 vibrant plum bags (and the 11 bags within each of those): 1 + 1*7 + 2 + 2*11 = 32 bags!
|
||||
//!
|
||||
//! Of course, the actual rules have a small chance of going several levels deeper than this example; be sure to count all of the bags, even if the nesting becomes topologically impractical!
|
||||
//!
|
||||
//! Here's another example:
|
||||
//!
|
||||
//! shiny gold bags contain 2 dark red bags.
|
||||
//! dark red bags contain 2 dark orange bags.
|
||||
//! dark orange bags contain 2 dark yellow bags.
|
||||
//! dark yellow bags contain 2 dark green bags.
|
||||
//! dark green bags contain 2 dark blue bags.
|
||||
//! dark blue bags contain 2 dark violet bags.
|
||||
//! dark violet bags contain no other bags.
|
||||
//! In this example, a single shiny gold bag must contain 126 other bags.
|
||||
//!
|
||||
//! How many individual bags are required inside your single shiny gold bag?
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
type Color = String;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Node {
|
||||
color: Color,
|
||||
parents: Vec<Color>,
|
||||
children: Vec<(usize, Color)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct Graph {
|
||||
nodes: HashMap<Color, Node>,
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
fn add_node(&mut self, line: &str) {
|
||||
let parts: Vec<_> = line.split(" bags contain ").collect();
|
||||
match parts.len() {
|
||||
0 | 1 => panic!(format!("line '{}' fails assumptions", line)),
|
||||
_ => {
|
||||
let parent_color = parts[0].to_string();
|
||||
let mut children = Vec::new();
|
||||
if parts[1] != "no other bags." {
|
||||
for chunk in parts[1].split(' ').collect::<Vec<_>>().chunks(4) {
|
||||
// [0] quantity
|
||||
// [1] color1
|
||||
// [2] color2
|
||||
// [3] bag/bags[,.]
|
||||
let color = format!("{} {}", chunk[1], chunk[2]);
|
||||
let c = self.nodes.entry(color.clone()).or_insert(Node {
|
||||
color: color.clone(),
|
||||
parents: Vec::new(),
|
||||
children: Vec::new(),
|
||||
});
|
||||
c.parents.push(parent_color.clone());
|
||||
let count = chunk[0].parse::<usize>().expect("couldn't parse bag count");
|
||||
children.push((count, color.clone()));
|
||||
}
|
||||
}
|
||||
// Get or create this parent color
|
||||
let mut p = self.nodes.entry(parent_color.clone()).or_insert(Node {
|
||||
color: parent_color.clone(),
|
||||
parents: Vec::new(),
|
||||
children: Vec::new(),
|
||||
});
|
||||
p.children = children;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn top_level(&self, color: &Color) -> HashSet<Color> {
|
||||
let n = self.nodes.get(color).expect("Couldn't find node");
|
||||
self.top_level_rec(n.parents.clone())
|
||||
}
|
||||
fn top_level_rec(&self, parents: Vec<Color>) -> HashSet<Color> {
|
||||
if parents.is_empty() {
|
||||
return HashSet::new();
|
||||
}
|
||||
|
||||
let mut set = HashSet::new();
|
||||
set.extend(parents.clone());
|
||||
parents.iter().for_each(|color| {
|
||||
let n = self.nodes.get(color).expect("Couldn't find node");
|
||||
set.extend(self.top_level_rec(n.parents.clone()));
|
||||
});
|
||||
set
|
||||
}
|
||||
|
||||
fn bag_count(&self, color: &Color) -> usize {
|
||||
let n = self.nodes.get(color).expect("Couldn't find node");
|
||||
if n.children.is_empty() {
|
||||
// No children.
|
||||
return 0;
|
||||
} else {
|
||||
// Number of children bags and multiple the number of child bags by the transitive
|
||||
// closure of the child's sub bags.
|
||||
n.children
|
||||
.iter()
|
||||
// Return the number of sub
|
||||
.map(|(cnt, color)| cnt + cnt * self.bag_count(color))
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc_generator(day7)]
|
||||
fn parse(input: &str) -> Graph {
|
||||
let mut g = Graph::default();
|
||||
input.split('\n').for_each(|line| g.add_node(line));
|
||||
g
|
||||
}
|
||||
|
||||
#[aoc(day7, part1)]
|
||||
fn solution1(g: &Graph) -> usize {
|
||||
let answer = g.top_level(&"shiny gold".to_string()).len();
|
||||
|
||||
/*
|
||||
// Ensure we don't break part 1 while working on part 2.
|
||||
let correct_answer = 222;
|
||||
assert_eq!(answer, correct_answer);
|
||||
*/
|
||||
answer
|
||||
}
|
||||
|
||||
#[aoc(day7, part2)]
|
||||
fn solution2(g: &Graph) -> usize {
|
||||
g.bag_count(&"shiny gold".to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT1: &'static str = r#"light red bags contain 1 bright white bag, 2 muted yellow bags.
|
||||
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
|
||||
bright white bags contain 1 shiny gold bag.
|
||||
muted yellow bags contain 2 shiny gold bags, 9 faded blue bags.
|
||||
shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags.
|
||||
dark olive bags contain 3 faded blue bags, 4 dotted black bags.
|
||||
vibrant plum bags contain 5 faded blue bags, 6 dotted black bags.
|
||||
faded blue bags contain no other bags.
|
||||
dotted black bags contain no other bags."#;
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&parse(INPUT1)), 4);
|
||||
}
|
||||
|
||||
const INPUT2: &'static str = r#"shiny gold bags contain 2 dark red bags.
|
||||
dark red bags contain 2 dark orange bags.
|
||||
dark orange bags contain 2 dark yellow bags.
|
||||
dark yellow bags contain 2 dark green bags.
|
||||
dark green bags contain 2 dark blue bags.
|
||||
dark blue bags contain 2 dark violet bags.
|
||||
dark violet bags contain no other bags."#;
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(&parse(INPUT1)), 32);
|
||||
assert_eq!(solution2(&parse(INPUT2)), 126);
|
||||
}
|
||||
}
|
||||
245
2020/src/day8.rs
Normal file
245
2020/src/day8.rs
Normal file
@@ -0,0 +1,245 @@
|
||||
//! --- Day 8: Handheld Halting ---
|
||||
//! Your flight to the major airline hub reaches cruising altitude without incident. While you consider checking the in-flight menu for one of those drinks that come with a little umbrella, you are interrupted by the kid sitting next to you.
|
||||
//!
|
||||
//! Their handheld game console won't turn on! They ask if you can take a look.
|
||||
//!
|
||||
//! You narrow the problem down to a strange infinite loop in the boot code (your puzzle input) of the device. You should be able to fix it, but first you need to be able to run the code in isolation.
|
||||
//!
|
||||
//! The boot code is represented as a text file with one instruction per line of text. Each instruction consists of an operation (acc, jmp, or nop) and an argument (a signed number like +4 or -20).
|
||||
//!
|
||||
//! acc increases or decreases a single global value called the accumulator by the value given in the argument. For example, acc +7 would increase the accumulator by 7. The accumulator starts at 0. After an acc instruction, the instruction immediately below it is executed next.
|
||||
//! jmp jumps to a new instruction relative to itself. The next instruction to execute is found using the argument as an offset from the jmp instruction; for example, jmp +2 would skip the next instruction, jmp +1 would continue to the instruction immediately below it, and jmp -20 would cause the instruction 20 lines above to be executed next.
|
||||
//! nop stands for No OPeration - it does nothing. The instruction immediately below it is executed next.
|
||||
//! For example, consider the following program:
|
||||
//!
|
||||
//! nop +0
|
||||
//! acc +1
|
||||
//! jmp +4
|
||||
//! acc +3
|
||||
//! jmp -3
|
||||
//! acc -99
|
||||
//! acc +1
|
||||
//! jmp -4
|
||||
//! acc +6
|
||||
//! These instructions are visited in this order:
|
||||
//!
|
||||
//! nop +0 | 1
|
||||
//! acc +1 | 2, 8(!)
|
||||
//! jmp +4 | 3
|
||||
//! acc +3 | 6
|
||||
//! jmp -3 | 7
|
||||
//! acc -99 |
|
||||
//! acc +1 | 4
|
||||
//! jmp -4 | 5
|
||||
//! acc +6 |
|
||||
//! First, the nop +0 does nothing. Then, the accumulator is increased from 0 to 1 (acc +1) and jmp +4 sets the next instruction to the other acc +1 near the bottom. After it increases the accumulator from 1 to 2, jmp -4 executes, setting the next instruction to the only acc +3. It sets the accumulator to 5, and jmp -3 causes the program to continue back at the first acc +1.
|
||||
//!
|
||||
//! This is an infinite loop: with this sequence of jumps, the program will run forever. The moment the program tries to run any instruction a second time, you know it will never terminate.
|
||||
//!
|
||||
//! Immediately before the program would run an instruction a second time, the value in the accumulator is 5.
|
||||
//!
|
||||
//! Run your copy of the boot code. Immediately before any instruction is executed a second time, what value is in the accumulator?
|
||||
//!
|
||||
|
||||
//! --- Part Two ---
|
||||
//! After some careful analysis, you believe that exactly one instruction is corrupted.
|
||||
//!
|
||||
//! Somewhere in the program, either a jmp is supposed to be a nop, or a nop is supposed to be a jmp. (No acc instructions were harmed in the corruption of this boot code.)
|
||||
//!
|
||||
//! The program is supposed to terminate by attempting to execute an instruction immediately after the last instruction in the file. By changing exactly one jmp or nop, you can repair the boot code and make it terminate correctly.
|
||||
//!
|
||||
//! For example, consider the same program from above:
|
||||
//!
|
||||
//! nop +0
|
||||
//! acc +1
|
||||
//! jmp +4
|
||||
//! acc +3
|
||||
//! jmp -3
|
||||
//! acc -99
|
||||
//! acc +1
|
||||
//! jmp -4
|
||||
//! acc +6
|
||||
//! If you change the first instruction from nop +0 to jmp +0, it would create a single-instruction infinite loop, never leaving that instruction. If you change almost any of the jmp instructions, the program will still eventually find another jmp instruction and loop forever.
|
||||
//!
|
||||
//! However, if you change the second-to-last instruction (from jmp -4 to nop -4), the program terminates! The instructions are visited in this order:
|
||||
//!
|
||||
//! nop +0 | 1
|
||||
//! acc +1 | 2
|
||||
//! jmp +4 | 3
|
||||
//! acc +3 |
|
||||
//! jmp -3 |
|
||||
//! acc -99 |
|
||||
//! acc +1 | 4
|
||||
//! nop -4 | 5
|
||||
//! acc +6 | 6
|
||||
//! After the last instruction (acc +6), the program terminates by attempting to run the instruction below the last instruction in the file. With this change, after the program terminates, the accumulator contains the value 8 (acc +1, acc +1, acc +6).
|
||||
//!
|
||||
//! Fix the program so that it terminates normally by changing exactly one jmp (to nop) or nop (to jmp). What is the value of the accumulator after the program terminates?
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use aoc_runner_derive::aoc;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
enum Instruction {
|
||||
Nop(i32),
|
||||
Acc(i32),
|
||||
Jmp(i32),
|
||||
}
|
||||
impl FromStr for Instruction {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut it = s.split(' ');
|
||||
Ok(match it.next() {
|
||||
Some("nop") => Instruction::Nop(it.next().ok_or(())?.parse().map_err(|_| ())?),
|
||||
Some("acc") => Instruction::Acc(it.next().ok_or(())?.parse().map_err(|_| ())?),
|
||||
Some("jmp") => Instruction::Jmp(it.next().ok_or(())?.parse().map_err(|_| ())?),
|
||||
Some(c) => panic!(format!("unknown instruction '{}'", c)),
|
||||
None => panic!(format!("no space in '{}'", s)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq)]
|
||||
struct Program {
|
||||
ip: usize,
|
||||
acc: i32,
|
||||
intrs: Vec<Instruction>,
|
||||
executed: Vec<bool>,
|
||||
}
|
||||
|
||||
impl Program {
|
||||
fn reset(&mut self) {
|
||||
self.ip = 0;
|
||||
self.acc = 0;
|
||||
self.executed.iter_mut().for_each(|i| *i = false);
|
||||
}
|
||||
fn debug(&mut self, bad_ip: usize) -> Option<i32> {
|
||||
loop {
|
||||
if self.executed[self.ip] {
|
||||
return None;
|
||||
}
|
||||
self.executed[self.ip] = true;
|
||||
let intr = self.intrs[self.ip];
|
||||
let intr = if self.ip == bad_ip {
|
||||
match intr {
|
||||
// Swap instruction as this is a possible bug location.
|
||||
Instruction::Nop(op) => Instruction::Jmp(op),
|
||||
Instruction::Jmp(op) => Instruction::Nop(op),
|
||||
// Acc can't be buggy per the instructions.
|
||||
Instruction::Acc(_) => return None,
|
||||
}
|
||||
} else {
|
||||
intr
|
||||
};
|
||||
match intr {
|
||||
Instruction::Nop(_) => self.ip += 1,
|
||||
Instruction::Acc(op) => {
|
||||
self.acc += op;
|
||||
self.ip += 1;
|
||||
}
|
||||
Instruction::Jmp(op) => self.ip = (self.ip as i32 + op) as usize,
|
||||
}
|
||||
if self.ip >= self.intrs.len() {
|
||||
return Some(self.acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run(&mut self) -> i32 {
|
||||
loop {
|
||||
if self.executed[self.ip] {
|
||||
return self.acc;
|
||||
}
|
||||
self.executed[self.ip] = true;
|
||||
match self.intrs[self.ip] {
|
||||
Instruction::Nop(_) => self.ip += 1,
|
||||
Instruction::Acc(op) => {
|
||||
self.acc += op;
|
||||
self.ip += 1;
|
||||
}
|
||||
Instruction::Jmp(op) => self.ip = (self.ip as i32 + op) as usize,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Program {
|
||||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let intrs: Vec<_> = s.split('\n').filter_map(|i| i.parse().ok()).collect();
|
||||
let executed = vec![false; intrs.len()];
|
||||
Ok(Program {
|
||||
ip: 0,
|
||||
acc: 0,
|
||||
intrs,
|
||||
executed,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[aoc(day8, part1)]
|
||||
fn solution1(input: &str) -> i32 {
|
||||
let mut p: Program = input.parse().expect("Failed to parse Program");
|
||||
p.run()
|
||||
}
|
||||
|
||||
#[aoc(day8, part2)]
|
||||
fn solution2(input: &str) -> i32 {
|
||||
let mut p: Program = input.parse().expect("Failed to parse Program");
|
||||
for bad_ip in 0..p.intrs.len() {
|
||||
if let Some(acc) = p.debug(bad_ip) {
|
||||
return acc;
|
||||
}
|
||||
p.reset();
|
||||
}
|
||||
panic!("no bugfix found")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const INPUT1: &'static str = r#"nop +0
|
||||
acc +1
|
||||
jmp +4
|
||||
acc +3
|
||||
jmp -3
|
||||
acc -99
|
||||
acc +1
|
||||
jmp -4
|
||||
acc +6"#;
|
||||
|
||||
#[test]
|
||||
fn make() {
|
||||
assert_eq!(
|
||||
INPUT1.parse::<Program>().expect("Failed to parse input"),
|
||||
Program {
|
||||
ip: 0,
|
||||
acc: 0,
|
||||
intrs: vec![
|
||||
Instruction::Nop(0),
|
||||
Instruction::Acc(1),
|
||||
Instruction::Jmp(4),
|
||||
Instruction::Acc(3),
|
||||
Instruction::Jmp(-3),
|
||||
Instruction::Acc(-99),
|
||||
Instruction::Acc(1),
|
||||
Instruction::Jmp(-4),
|
||||
Instruction::Acc(6),
|
||||
],
|
||||
executed: vec![false; 9],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1(&INPUT1), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2(&INPUT1), 8);
|
||||
}
|
||||
}
|
||||
208
2020/src/day9.rs
Normal file
208
2020/src/day9.rs
Normal file
@@ -0,0 +1,208 @@
|
||||
//! --- Day 9: Encoding Error ---
|
||||
//! With your neighbor happily enjoying their video game, you turn your attention to an open data port on the little screen in the seat in front of you.
|
||||
//!
|
||||
//! Though the port is non-standard, you manage to connect it to your computer through the clever use of several paperclips. Upon connection, the port outputs a series of numbers (your puzzle input).
|
||||
//!
|
||||
//! The data appears to be encrypted with the eXchange-Masking Addition System (XMAS) which, conveniently for you, is an old cypher with an important weakness.
|
||||
//!
|
||||
//! XMAS starts by transmitting a preamble of 25 numbers. After that, each number you receive should be the sum of any two of the 25 immediately previous numbers. The two numbers will have different values, and there might be more than one such pair.
|
||||
//!
|
||||
//! For example, suppose your preamble consists of the numbers 1 through 25 in a random order. To be valid, the next number must be the sum of two of those numbers:
|
||||
//!
|
||||
//! 26 would be a valid next number, as it could be 1 plus 25 (or many other pairs, like 2 and 24).
|
||||
//! 49 would be a valid next number, as it is the sum of 24 and 25.
|
||||
//! 100 would not be valid; no two of the previous 25 numbers sum to 100.
|
||||
//! 50 would also not be valid; although 25 appears in the previous 25 numbers, the two numbers in the pair must be different.
|
||||
//! Suppose the 26th number is 45, and the first number (no longer an option, as it is more than 25 numbers ago) was 20. Now, for the next number to be valid, there needs to be some pair of numbers among 1-19, 21-25, or 45 that add up to it:
|
||||
//!
|
||||
//! 26 would still be a valid next number, as 1 and 25 are still within the previous 25 numbers.
|
||||
//! 65 would not be valid, as no two of the available numbers sum to it.
|
||||
//! 64 and 66 would both be valid, as they are the result of 19+45 and 21+45 respectively.
|
||||
//! Here is a larger example which only considers the previous 5 numbers (and has a preamble of length 5):
|
||||
//!
|
||||
//! 35
|
||||
//! 20
|
||||
//! 15
|
||||
//! 25
|
||||
//! 47
|
||||
//! 40
|
||||
//! 62
|
||||
//! 55
|
||||
//! 65
|
||||
//! 95
|
||||
//! 102
|
||||
//! 117
|
||||
//! 150
|
||||
//! 182
|
||||
//! 127
|
||||
//! 219
|
||||
//! 299
|
||||
//! 277
|
||||
//! 309
|
||||
//! 576
|
||||
//! In this example, after the 5-number preamble, almost every number is the sum of two of the previous 5 numbers; the only number that does not follow this rule is 127.
|
||||
//!
|
||||
//! The first step of attacking the weakness in the XMAS data is to find the first number in the list (after the preamble) which is not the sum of two of the 25 numbers before it. What is the first number that does not have this property?
|
||||
//!
|
||||
//! --- Part Two ---
|
||||
//! The final step in breaking the XMAS encryption relies on the invalid number you just found: you must find a contiguous set of at least two numbers in your list which sum to the invalid number from step 1.
|
||||
//!
|
||||
//! Again consider the above example:
|
||||
//!
|
||||
//! 35
|
||||
//! 20
|
||||
//! 15
|
||||
//! 25
|
||||
//! 47
|
||||
//! 40
|
||||
//! 62
|
||||
//! 55
|
||||
//! 65
|
||||
//! 95
|
||||
//! 102
|
||||
//! 117
|
||||
//! 150
|
||||
//! 182
|
||||
//! 127
|
||||
//! 219
|
||||
//! 299
|
||||
//! 277
|
||||
//! 309
|
||||
//! 576
|
||||
//! In this list, adding up all of the numbers from 15 through 40 produces the invalid number from step 1, 127. (Of course, the contiguous set of numbers in your actual list might be much longer.)
|
||||
//!
|
||||
//! To find the encryption weakness, add together the smallest and largest number in this contiguous range; in this example, these are 15 and 47, producing 62.
|
||||
//!
|
||||
//! What is the encryption weakness in your XMAS-encrypted list of numbers?
|
||||
|
||||
use aoc_runner_derive::{aoc, aoc_generator};
|
||||
|
||||
#[aoc_generator(day9)]
|
||||
fn parse(input: &str) -> Vec<usize> {
|
||||
input
|
||||
.split('\n')
|
||||
.map(|s| s.parse::<usize>().unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn solution1_impl(nums: &[usize], win_size: usize) -> usize {
|
||||
nums.windows(win_size + 1)
|
||||
.skip_while(|chunk| {
|
||||
let past = &chunk[..win_size];
|
||||
let cur = chunk[win_size];
|
||||
for p in past {
|
||||
let diff = if cur > *p { cur - p } else { p - cur };
|
||||
if past.contains(&diff) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
})
|
||||
.find_map(|chunk| Some(chunk[win_size]))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn solution1_impl_sorted(nums: &[usize], win_size: usize) -> usize {
|
||||
nums.windows(win_size + 1)
|
||||
.skip_while(|chunk| {
|
||||
let mut past = (&chunk[..win_size]).clone().to_owned();
|
||||
past.sort_unstable();
|
||||
let cur = chunk[win_size];
|
||||
for p in &past {
|
||||
let diff = if cur > *p { cur - p } else { p - cur };
|
||||
if past.binary_search(&diff).is_ok() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
})
|
||||
.find_map(|chunk| Some(chunk[win_size]))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[aoc(day9, part1)]
|
||||
fn solution1(nums: &[usize]) -> usize {
|
||||
solution1_impl(nums, 25)
|
||||
}
|
||||
|
||||
#[aoc(day9, part1, sorted)]
|
||||
fn solution1_sorted(nums: &[usize]) -> usize {
|
||||
solution1_impl_sorted(nums, 25)
|
||||
}
|
||||
|
||||
fn sum_min_max(low: usize, hi: usize, nums: &[usize]) -> usize {
|
||||
let (min, max) = nums[low..hi]
|
||||
.iter()
|
||||
.fold((usize::MAX, 0), |(min, max), &n| {
|
||||
(std::cmp::min(min, n), std::cmp::max(max, n))
|
||||
});
|
||||
min + max
|
||||
}
|
||||
|
||||
// If contiguous numbers adding up to `sum` are found, the hi index (inclusive) is returned.
|
||||
fn find_sum_at(low: usize, nums: &[usize], sum: usize) -> Option<usize> {
|
||||
let mut p_sum = nums[low];
|
||||
for hi in low + 1..nums.len() {
|
||||
let n = nums[hi];
|
||||
p_sum += n;
|
||||
if p_sum == sum {
|
||||
return Some(hi + 1);
|
||||
}
|
||||
if p_sum > sum {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn solution2_impl(nums: &[usize], win_size: usize) -> usize {
|
||||
let sum = solution1_impl(nums, win_size);
|
||||
for low in 0..nums.len() - 1 {
|
||||
if let Some(hi) = find_sum_at(low, nums, sum) {
|
||||
return sum_min_max(low, hi, nums);
|
||||
}
|
||||
}
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
#[aoc(day9, part2)]
|
||||
fn solution2(nums: &[usize]) -> usize {
|
||||
solution2_impl(nums, 25)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
const INPUT: &'static str = r#"35
|
||||
20
|
||||
15
|
||||
25
|
||||
47
|
||||
40
|
||||
62
|
||||
55
|
||||
65
|
||||
95
|
||||
102
|
||||
117
|
||||
150
|
||||
182
|
||||
127
|
||||
219
|
||||
299
|
||||
277
|
||||
309
|
||||
576"#;
|
||||
|
||||
#[test]
|
||||
fn part1() {
|
||||
assert_eq!(solution1_impl(&parse(&INPUT), 5), 127);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2() {
|
||||
assert_eq!(solution2_impl(&parse(&INPUT), 5), 62);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,22 @@
|
||||
mod day1;
|
||||
mod day2;
|
||||
mod day3;
|
||||
pub mod day1;
|
||||
pub mod day10;
|
||||
pub mod day11;
|
||||
pub mod day12;
|
||||
pub mod day13;
|
||||
pub mod day14;
|
||||
pub mod day15;
|
||||
pub mod day16;
|
||||
pub mod day17;
|
||||
//pub mod day18;
|
||||
pub mod day19;
|
||||
pub mod day2;
|
||||
pub mod day3;
|
||||
pub mod day4;
|
||||
pub mod day5;
|
||||
pub mod day6;
|
||||
pub mod day7;
|
||||
pub mod day8;
|
||||
pub mod day9;
|
||||
|
||||
use aoc_runner_derive::aoc_lib;
|
||||
|
||||
|
||||
5
2020/src/main.rs
Normal file
5
2020/src/main.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
use advent2020;
|
||||
|
||||
use aoc_runner_derive::aoc_main;
|
||||
|
||||
aoc_main! { lib = advent2020 }
|
||||
Reference in New Issue
Block a user