File tree 5 files changed +222
-0
lines changed
5 files changed +222
-0
lines changed Original file line number Diff line number Diff line change
1
+ 178
2
+ 135
3
+ 78
4
+ 181
5
+ 137
6
+ 16
7
+ 74
8
+ 11
9
+ 142
10
+ 109
11
+ 148
12
+ 108
13
+ 151
14
+ 184
15
+ 121
16
+ 58
17
+ 110
18
+ 52
19
+ 169
20
+ 128
21
+ 2
22
+ 119
23
+ 38
24
+ 136
25
+ 25
26
+ 26
27
+ 73
28
+ 157
29
+ 153
30
+ 7
31
+ 19
32
+ 160
33
+ 4
34
+ 80
35
+ 10
36
+ 51
37
+ 1
38
+ 131
39
+ 55
40
+ 86
41
+ 87
42
+ 21
43
+ 46
44
+ 88
45
+ 173
46
+ 71
47
+ 64
48
+ 114
49
+ 120
50
+ 167
51
+ 172
52
+ 145
53
+ 130
54
+ 33
55
+ 20
56
+ 190
57
+ 35
58
+ 79
59
+ 162
60
+ 122
61
+ 98
62
+ 177
63
+ 179
64
+ 68
65
+ 48
66
+ 118
67
+ 125
68
+ 192
69
+ 174
70
+ 99
71
+ 152
72
+ 3
73
+ 89
74
+ 105
75
+ 180
76
+ 191
77
+ 61
78
+ 13
79
+ 90
80
+ 129
81
+ 47
82
+ 138
83
+ 67
84
+ 115
85
+ 44
86
+ 59
87
+ 60
88
+ 95
89
+ 93
90
+ 166
91
+ 154
92
+ 101
93
+ 34
94
+ 113
95
+ 139
96
+ 77
97
+ 94
98
+ 161
99
+ 187
100
+ 45
101
+ 22
102
+ 12
103
+ 163
104
+ 41
105
+ 27
106
+ 132
107
+ 30
108
+ 143
109
+ 168
110
+ 144
111
+ 83
112
+ 100
113
+ 102
114
+ 72
Original file line number Diff line number Diff line change
1
+ 28
2
+ 33
3
+ 18
4
+ 42
5
+ 31
6
+ 14
7
+ 46
8
+ 20
9
+ 48
10
+ 47
11
+ 24
12
+ 23
13
+ 49
14
+ 45
15
+ 19
16
+ 38
17
+ 39
18
+ 11
19
+ 1
20
+ 32
21
+ 25
22
+ 35
23
+ 8
24
+ 17
25
+ 7
26
+ 9
27
+ 4
28
+ 2
29
+ 34
30
+ 10
31
+ 3
Original file line number Diff line number Diff line change
1
+ 16
2
+ 10
3
+ 15
4
+ 5
5
+ 1
6
+ 11
7
+ 7
8
+ 19
9
+ 6
10
+ 12
11
+ 4
Original file line number Diff line number Diff line change
1
+ from aoc import *
2
+
3
+
4
+
5
+ FILE = '10_test0.txt'
6
+ FILE = '10_test.txt'
7
+ FILE = '10.txt'
8
+
9
+
10
+ def main ():
11
+ inp = load_ints (FILE )
12
+ out = 0
13
+ cnt1 = 0
14
+ cnt2 = 1
15
+ inp .sort ()
16
+ print (inp )
17
+ for i , j in enumerate (inp ):
18
+ if i == 0 :
19
+ prev = 0
20
+ else :
21
+ prev = inp [i - 1 ]
22
+ if j - prev == 1 :
23
+ cnt1 += 1
24
+ elif j - prev == 3 :
25
+ cnt2 += 1
26
+ else :
27
+ print ('something else' )
28
+ out = cnt1 * cnt2
29
+ print (out )
30
+
31
+
32
+ main ()
Original file line number Diff line number Diff line change
1
+ from aoc import *
2
+ import functools
3
+
4
+
5
+ FILE = '10_test.txt'
6
+ FILE = '10.txt'
7
+ # FILE = '10_test0.txt'
8
+
9
+
10
+ @functools .cache
11
+ def how_many (value : int , nset : frozenset ):
12
+ cnt = 0
13
+ if value + 1 in nset :
14
+ cnt += how_many (value + 1 , nset )
15
+ if value + 2 in nset :
16
+ cnt += how_many (value + 2 , nset )
17
+ if value + 3 in nset :
18
+ cnt += how_many (value + 3 , nset )
19
+ if cnt == 0 :
20
+ return 1
21
+ return cnt
22
+
23
+
24
+ def main ():
25
+ inp = load_ints (FILE )
26
+ inp .sort ()
27
+ inp .insert (0 , 0 )
28
+ inp .append (inp [- 1 ]+ 3 )
29
+ nset = frozenset (inp )
30
+ out = how_many (0 , nset )
31
+ print (out )
32
+
33
+
34
+ main ()
You can’t perform that action at this time.
0 commit comments