Jens Kadenbach 1年前
コミット
0a6181ccc0
6個のファイルの変更737行の追加1行の削除
  1. 2
    0
      aoc2022.cabal
  2. 449
    0
      ressources/day13-input
  3. 96
    0
      ressources/day13.py
  4. 117
    0
      src/Day13.hs
  5. 2
    1
      src/Lib.hs
  6. 71
    0
      test/Day13Spec.hs

+ 2
- 0
aoc2022.cabal ファイルの表示

@@ -31,6 +31,7 @@ library
31 31
       Day11
32 32
       Day11.Parser
33 33
       Day12
34
+      Day13
34 35
       Day2
35 36
       Day2.Part1
36 37
       Day2.Part2
@@ -117,6 +118,7 @@ test-suite aoc2022-test
117 118
       Day10Spec
118 119
       Day11Spec
119 120
       Day12Spec
121
+      Day13Spec
120 122
       Day1Spec
121 123
       Day2Spec
122 124
       Day3Spec

+ 449
- 0
ressources/day13-input ファイルの表示

@@ -0,0 +1,449 @@
1
+[[4,[1,[]]],[8,3,[[0,2],[5,2,6],[7,0,10,0],2,[5,7,10,2]],[[5,9],5,10,[9,7,7]]]]
2
+[[[],9],[[[3,2,6,3],[7,8]],10],[1]]
3
+
4
+[[],[0,4,[[2,9,0,1,2],[1,1,1,1],9,[2]]],[[],5]]
5
+[[[[4,6],[9,4,9,5],7,[1,3,6],[]]],[1,[]],[8,[6,[8],0,5],[],[[7,4,9],[4,2,8,2,2],[10,5,5,4],4]],[8,[7,[7,3],[4],10],[10],[[10,1]]],[]]
6
+
7
+[[0],[[[1],0,[],2,[4,5,6,3,2]],5,[],3],[[0,[8,8,5,2],10,[7,6,4,8],[4,9,3,9,5]],9,[4,6]],[[10,6,[10,2],8,[]],[10,[10,8,10,1,4],[0,6],4],8,[6,[5,3,3],6,[3,9,4,0],7]],[[4,8],[1,3,9],[[2],6],5,[0,[5,0],0,5]]]
8
+[[[[10,8],[3,6,7],3,[4]],[[8,10,8,4,0],[7,2],7,[2],[1,3]],3,[[0,7,9,1,10],[8,1,6]]]]
9
+
10
+[[[1,[5,2,6,6,0]],[[7,7],[]],[[4,5],[],[],[3,7,1,8],1]],[9,[[],[8,7,8,9]],[2,4,0,[7,4,4]],[1],[]],[[[],[4,7,0,4],[1,0]],5,4],[],[[9,[],[7]]]]
11
+[[[3],[[5,2,1]],2]]
12
+
13
+[[[[5,8,8,6],0]]]
14
+[[[[3,0,10,1,5],10,[7,0]],8,[0,9,4,[8,10]],[[6],[4,4,8],7,9,[9]]],[[7,[],0,2],[[]],5,6,[]],[0,[[1,10,8,8,1],2,[2,6],[10,9],[7]]],[2],[[[],2,5,[2,9,6,0],8],9]]
15
+
16
+[[],[6],[[0,[2],8,[]],[[0],9,5,[7,6,6,6,9],[3,1]],4,10],[[4,[5,1,9,4],2]]]
17
+[[[],[[3,7,5,4,1],[9,0,2,5,6],[4,3],2,[0,1,2,7,2]],[]],[[],2,5,3],[[2,9],1,10,0,1],[[4,9],[],[6,[],7,10,[10,9,1,10,9]],1,7]]
18
+
19
+[[10],[],[6,[],[]],[],[2,0,5]]
20
+[[6,1,[8,6,9]]]
21
+
22
+[[8,[[0,0],[],1,[8],8],4,[7,8,1,10],10],[]]
23
+[[[0],6],[[],3]]
24
+
25
+[[[8,[5],[4],[2,0]],[[1],1,[4,2,10,6]]],[[],[6,5,[6],[9,2,3]],[[6]]]]
26
+[[[6,2,4,[4,9],[2,4,10]]],[[3,[5,5,10,9,9],10,[6,2,8,7,9]],[],4],[[[3,2],[]]],[[[10,9],[3,10]],[0,1]]]
27
+
28
+[[[[8,10,1],10]],[7],[[9,[7],[0,9,8,4]]],[[4],4,0]]
29
+[[1,[],[[9,9,2],[10],[]]],[[[7],[],[],[],4],[[3],0,[5,7,1],6],3,10],[2]]
30
+
31
+[[10],[],[]]
32
+[[2,4,2,[[6],[1,10],4,9],3],[7,8,5],[[],0],[[5,[],[]],7]]
33
+
34
+[[5,3,[[7,6,10],10,7,[6,5,7,9],8],[],4],[0,[[6],[2,2,1,5,7],[1],[2],1],[2],[1,[7,1,3,0,3],[9],7,[1,9,6]]]]
35
+[[[4,[5,9,6,5,6],1,[6,4,4,4,9]],[[],6,[8,3],[2,1],9]],[6,[[10,1]],[7,[6,1]],[[6,3,8,2],8]],[2,7,[],7],[0,7,[[6],9,[4,10,6,6,4]],[]],[7,4,[8,[1,6,8,7]],9]]
36
+
37
+[[8],[[1,0,2,10,3],5],[],[9,[[1],[3,6,6,6,8],2,5,8],10,9,[3]],[4,6,1,[8]]]
38
+[[3,4],[[],[7,[1,10],[9,9,7,5,2],5]],[],[[0,[4,7],[2,7,3,8],3],[3],[[],[],9,[2,7,9]],[8,2,6]],[9,[]]]
39
+
40
+[[[[2,0,1],6,[1],7]],[7,10,2],[],[[]],[2,1,[[],9],[[6,9,9,6,0],[],[10,2]]]]
41
+[[4,[],6,5],[[],[[],[5,2]],[1,4],0,[[5],[9,9,4,1,5]]],[[],10,10,[8],[1,[8],2,9,2]],[7,3,[[0,8,5,2],[4,2,10],0]],[1,[[1,9,5],3,10,[10,8]],9,[[]]]]
42
+
43
+[[5,7,8,9],[6,9,[5],0,[7,[4],[9,7,1,1],7,6]],[[[8,2,9,6]],[8,5,[4,1,0]],[[2,6,3],[2],[4,0],[2,0,5]],6,[[9,6,7,4],[4],4,8,[9]]]]
44
+[[[8,3,[3],[7,5,10]],3,[5],9,0],[3],[[[9,6,0]],1],[3,10,[[9,8,6,10],4,[10,10],[10],[2,7]],2,10],[5]]
45
+
46
+[[],[4,[[7]],[[3,10],[5]]]]
47
+[[[[0,5,7],0,10],[[],2,8,3],1,[5,8]],[]]
48
+
49
+[[[],[[4,5],9,8,[4,2,7],[1,6]],[[]],1,[[1,10,9,10,4],2,4]],[8,[0,7,2,[3,8,4,9]],[[5,9,3],1]],[[[4],10,[5]],4],[5,[4,9,[]],1,1,8]]
50
+[[4],[1],[],[[[3,2,1,5,6]],[[4],[2,1,3]],[10,5]]]
51
+
52
+[[0,6],[],[[],7,9,5],[]]
53
+[[[5,[2,5,0,8,10],5,[10,8,10,7]],5,6],[[7,[]],10]]
54
+
55
+[[[[7,0,7],[8,4,10,2,6],[10,8,9],[10,3]],[[1,9,5,0],2,[1,8,1,8,2]]],[[[],[9,3],10,[1],9],[[9,9,6]],1,[0],9]]
56
+[[[[5,1,9,10,6],7]],[10,[4],[7],0],[1,8,[[],4,[10]],[[6,8,4,2],6,[],[10,8]]]]
57
+
58
+[[10,[[6,7,7],[5,5,1,4]],[1,0,0,7,[1,8,2]]],[4],[9],[[5],[10,[2,5,10]],5,[]]]
59
+[[8],[4,5],[6,[[9,1,5],[2,10,3,7,7],9]],[9,0,0,[],[0,[7,3],3]]]
60
+
61
+[[],[[[4,7,9,6]],2,10,[6]],[[[3,3,10,5],[2,6,1,5,2],[3],[],8],2,7],[6,9,[0,8,9,10,8]]]
62
+[[[4,0,[5]],0,[[],[1,6,5,5,5],[5,2,7,5],2],3,[9,[9,3,9,7,4]]],[8,[],[[1,1]],[[4,8,1],[7,6,8,8],[],10]],[4,[[6,6,3,10,2],[8,1,1,1,7]],[[3],9,[4,3,9,1,7]]],[[1,[8,6,3,1],[2,10,9]]]]
63
+
64
+[[[[1,4,10,6],10,[5,6,10,3]],8,[[]],[],6],[],[[9,[5,6],8],10],[2,[9,[5,3,10,4],10,[],[7,4,1,9]]]]
65
+[[4,[[]],[1,[10,8],7,[4],[0,3,2]]],[[[6,4,7,0]]],[10,7,[6,[1,2,8,4]],[9,[3,8,4,7,2]]],[4,[8,[6,10,10,9],[],9],6,[[4,8,3],10,1,2],8],[[7,7,[8,8,7,1,1],6],[[8,8,10,2,4],0]]]
66
+
67
+[[],[8],[8,10,0],[7,[[4,1,0],5]],[[[6,9,4],[9,1],[6,4,6,6,10],[]],3,7]]
68
+[[9],[3,6,[[1,7],[],9,[8]],[7,[9],3,[]],9],[0,[0,2]],[3]]
69
+
70
+[[7,[10,[3,0,10],5,[5,3,2],4]],[]]
71
+[[[5,8,3,[0,2,2,7,0],7],[[10,2,0,10,7],[0,3,10,10,5]],3,[8],[10,4,7,0]],[]]
72
+
73
+[[[0,[0,8,1],2],4,[],[9],10]]
74
+[[[3,6,[2,0]],5,[[7,2],[],3,5,4]],[[9]],[7,[6,[1,5],[9,6]],[[],9,[1],3],[10,[],0]],[[1,[5,6],9,[10,7,4,7,4]],[5,[0,7,0,0],6,[0,0]],[],[[10,1,9,9,6],[1,3],[8],3]],[[[],[]]]]
75
+
76
+[[9,[[4,3,0]]]]
77
+[[10,9],[[],[[0,8,0,8],[0,10,4,2]],[10,[0,0],[5,10,0,5],5],5]]
78
+
79
+[[[[8,5,4,6]]],[8,[2,0,[3,6,7,8],10,[3,8]]],[0,2,[[3,6,10,4],[8,7,6,6,2],9,[7,3,9,7]],[3,9],[9,[3,8,0],2,9,[4]]]]
80
+[[6,[6],4,[[10],[0,1,3,3,8],1,2],9],[[[0,5,7,6,7],[3,3,10,9,2],4],[[],5,1,4],[[8,10,1,4,1],3,5,1,2],[[1,6,6,0],[9,7,6,7]]],[]]
81
+
82
+[]
83
+[[8,0,[7,[10,10,8,6],5],6],[],[]]
84
+
85
+[[[[9,10,3],10,5,4],[[7,2]],1,6],[9,[5,[7,3,3,5,2]]],[6,[[1],[],[8,4,6,3,2]]]]
86
+[[[[2,8,2],[4,9],2,10,[3,6]],6],[1,8,2],[2,8],[[1,[5],6,[]],1,[1]]]
87
+
88
+[[[[0,2,1],9,1,[6,2]],8,1],[10,[],6,8,[1,0]],[1,2,[3,9,[3,6],[9,0,10],7]]]
89
+[[[[1,7,3,9,6],[],[],4],[],1,1],[[],10,10],[],[[3,5],[[10,3,10,9],3,9]],[0,[[],4,[6,2,3,9,7],[4,10,4,4]],[7,10,3,[1,0,4],[10,9,4]],4]]
90
+
91
+[[],[],[],[7],[0]]
92
+[[1,[]],[],[5,6]]
93
+
94
+[[6,2,0],[]]
95
+[[5,7,5,[[2],[3]],[[1],[2,9]]],[1],[[[5,1,1,9],[]],2,1,[9]],[[9,[],[9,4],0],3,2]]
96
+
97
+[[[2,10,0,2],[],5,[[7],[],[],[5,3],[7,9]],7],[],[],[]]
98
+[[1,8,[4,[],[],[5],[6]]]]
99
+
100
+[[2,[3,[],10]],[[],5,[],[[8,8,7]]],[4,[4,[2],[6,0,0,10,3]],[[1,4]],2]]
101
+[[8],[[[]],7],[10,9,2,[[8],6,6,[8,1,4,5]]]]
102
+
103
+[[8],[[8,[10,10,9]],3],[4,[],[1]]]
104
+[[4,[6],[5]],[],[[10,0,3],10,5,3]]
105
+
106
+[[],[[[10,2,6],[1,4,9,2,5]],[],[5,2],[1,3,5]],[[[7,2,2,0],[0,1],10],10,[9,[4,8],[8,2,10],[1,4,2]],7,[[2]]]]
107
+[[],[[[],[],[9,10,5,6],2,[0]],10],[[],[[4,9,3,7],7,4],[],2,2],[8,[6,8,[7,5,5],[2,4,8,0,7],[3,1,7,3,9]],[[9,1,5,1],[5,1,1],[],[2,1,2,1]],[[0,9,1,10],5,[],10,[5,0,10,2]],[10,[3,4,8,8,4],5]]]
108
+
109
+[[[[8,6,7,6,1],[4,2,7,1,3],[]],[]],[[7,[3,10,6],[3,6,5,8,0]],0,[],0],[6,[6,8,[5],4,2],7,[[0],5]]]
110
+[[6,5,6,10],[[[1,3,3]],1,2,[[5,0,10,2,10],[4,7,7,0],2,[2]],7],[[2,4,6,6],9,[[0,1,9],[10],9,[2,7,6,5,2],3],3,7],[[[8,4,6,1,1],[9],2]]]
111
+
112
+[[6,1,[],1],[[],[[],3,8,[6,1,10,9,2],[7,0,1,10,2]],[]],[9,[6,9,[4,10],7],1,9]]
113
+[[[],[[]],5,[[7,8],[3,0,9,2,0],7]]]
114
+
115
+[[[],[[2,6],6],[],10],[],[[[6,6,10,2,8],[7,4,2]],[8,4,7,5],[5,[6,10],[]],[3],8]]
116
+[[[],6,3,[[3,4,8]]],[1,3,[5,4],[[4]],2]]
117
+
118
+[[],[[[5,10],6],2]]
119
+[[[7,[3,9,2],[],1],[3,7,[2,9,0,0],[3]],9],[[],[[4,10],4,[],[10,3,7,3],[10,0,7]]]]
120
+
121
+[[9,7,5],[3,4]]
122
+[[],[],[5,8,[[8,3,2],[6,1,0,7],[],[9,0,9],[8]],2]]
123
+
124
+[[[4,4,0,6,[8]],[1,[2,0],[4],[5,6,0,4,9]],3,[[6,1,7,7,4],[],[6,9,9,10,10],[4,3,9,3,4],[1,2,1,3]],1],[5,6,8,[],3],[[[9,3,10,3,3],9,[3,8,9,10,10]]],[[[5],6]]]
125
+[[],[[5,1,5,5],0,[7,3,[6,6,9],[10,5,6],[0,7,4,2]],1],[4,1,[[6,2,8,1,0],[8],[5,4]],2,6],[[[8],7],[1,1,7],[[5]]]]
126
+
127
+[[[[],4,[]],[[3,3,7],[3,4,10,1,9],2],[[5,8,9,5,7],[4,3,4,9],9,1],5],[[[6,7,6,10],[2,4,0,3],5,[0,0,8,6,8],8],[2,8],10]]
128
+[[[4,[2,0,6,6,7],[8,4,8,5,2]]],[[],2,[5,[],3,[8,10]],[],2],[],[],[[0,[4,9,2],[5,5,1,5],10,6],8,[10,[1,8,4,7]],[[0,1,5,5,2]],[]]]
129
+
130
+[[[2],[[3,10,0,5],[10,3,10,8],0,[]],8,[10,6,[5,2,4,5],[1]]],[],[[],[7,[0,10,4],[6,2,7],1,[1,4]]],[7,[],[[7,9],3,3]],[8,[[],[1],8],3]]
131
+[[[]]]
132
+
133
+[[[[0,1]]],[2,[10,[3,8,3],[3],[]],4,[[10,5,9,0],[5,2,8],[8,7,7,0,6],9],3],[10,[3,9,9,[7,4,0,9]],3]]
134
+[[],[[[5,8,0,4,8]],10,[5,[]],9],[[[8,1,6,4],5,4,[8,9,0,5]],1],[],[[[],7]]]
135
+
136
+[[[8],6,[3,[0,10,2],5,7,[2]],[10,9,7],3],[[[7,0,10,8,4],[6],7,8],[[7,4,7,6]],[[1],[4],2],[],[3,[4]]],[10,[]],[0,[[2,3,10,5],10,[10,10,0],[5,0],[8]],8,[[8,2,2],4,[],[0,3,10,4]]],[0,[10,[4,2,4,2,2]],8,[[9,1,2],5,[9,0,8,3,4],6,[10,3,4,5,2]],1]]
137
+[[[],[9,8]],[],[[[8],3,[0,1,6],[1,3],[9,8,9,8]],7,[[3,1],[2,0,1,6,10],4],5,[0,[0,6,1,5],[8,8,2,8,6],6,7]],[[8,6],9,8],[]]
138
+
139
+[[[10,[3,4,1,1]]],[[],9,8]]
140
+[[1,8,8,4,[6]],[]]
141
+
142
+[[0,0,6],[2,6,[[],[0,2],10,[10,9],2]]]
143
+[[1],[[[3,4,1,10,4],[7,10,3],[],[3,10,10,0]],[],4,[[0,5,0,0,9],6,[7,4,8,10,3]]]]
144
+
145
+[[[],[0,[9,9,5],[4,6],[1,7],[1,3,6,10,1]]]]
146
+[[],[],[0,[9,6],[2,7,[4,6]],[[2,5],10,[3,0,10]],0]]
147
+
148
+[[],[8,[2,3,[0,6],7]],[]]
149
+[[2,7,2,[0,[2,6],[],3,[9,3,9,6]],8]]
150
+
151
+[[[[5,8,8,10],1,[10,8,10,5],[5,2,0],[0,7,0]],[]],[[[10]],[],10],[[],[],6]]
152
+[[[3,[2,1],[],[],[]],0,3],[[],8,[],1,[7,0,[2,3,1,9],[9,0,4,6,2]]],[[[0,9],7,9,2,[4,3]],5,[3,[5,3,6],[],[]],[[7,10,0],[9,5,6],[0,8,4,1],[5,4,8],1]],[],[[[9,4,6],[9,4,3,8,5],4],[7,[6,2,7,3]],4,[]]]
153
+
154
+[[7,[[7,10],[0,1,3],[2,7,4,10],7,[1,2]],9],[[[],[10,6,3,4],[10,7,1]],[[],[10,8,10,6],[7,7,3,6,0],[7,5],[1,8]],1,0],[[],1]]
155
+[[],[[8,5],7,10,[10]],[[[],[4,0],[10,0,0,2,1]],[[9,7,9,9,0],9,9,[6,5],[4,9,7,3,10]],1,[[8,2,8,9]],0],[0,[[],10,0,3,3],5,[]]]
156
+
157
+[[],[7,[0]],[9,[3,[7,3,9],1,[8,1,5,3,6],[]]],[10],[2,5,7,6]]
158
+[[],[4,[],10,8,[9,7]],[8,10,9,[0,10]]]
159
+
160
+[[[],[],[2,[7,8],10]],[[],[2,[8,6,2],3,[7,3,9]],8],[5,[[1,7,2,6,6],0,6,[8,0],[6,10,0]],7],[]]
161
+[[4,3,[[6,6]],0,7],[[[4,0,2,9]],[4,[1,10,9,5],1,[],[4,4,2]],[1,[],[4,5,5,0,8],[9,5,10,7],7],8,2],[[[7,0],7,2],8,[],[[5],1,0,[0,2,6,7],[5,6,5,5,2]],8],[8,1,[6,4,[5]],0,[4,9,[],[4,3,0,3,8],[]]]]
162
+
163
+[[9,[[5,10,9,4],4],7],[[9,[],2,3,[2]],5,0,[[4,10,1,7,6],4,7,9],[4,[6,4,3],[6,4],[5],8]],[[[0,10,1,4,9],6,[9,2,1],[5,2,3]],[],[9,0,[1,0,9,6],[2]],[3,[9,2]],[10,[5,7,5,2,1],10,9,3]]]
164
+[[0,[[4,2,5,8],[8,7,9]],[6,0,10],9,[[2,9,1,9,3]]],[3,[2,[0,0],[4,3,0]],[1]],[],[3,[[5,1,3,2],7,2]]]
165
+
166
+[[[[9,5,5,1,1],10,7],[[3,9],9,[8,6,3,6,1]],[],[[2]]],[[1,[8],4],[10,10,3,3]]]
167
+[[[[3,5,8,1],9,[6,6,3,3,2]]],[3],[7]]
168
+
169
+[[[[0,10,1,4],4,[3,8],7],0,2,[[5,2,4,0,6],[7,5,9],[],[2,2,2,6,8],[6,9,9,3]]],[5,4],[],[[0,5],7,7,7]]
170
+[[10,[[5],[10],6,10,3],[[4,10,2],0,[10]],8],[[[],4,[7,6,6]],5,[3,3,[0,7],8],2,9],[]]
171
+
172
+[[3],[[]],[10,[1,1,[2,10,1]],[[1],2,[0,10,4],4,6]],[],[8,[3,5],[10,0,10,4,[]],[[0,4,6],3,3]]]
173
+[[[],[[0,7],7,4,[0,6,1],[8,3,7]],5,3,0],[],[[5,7,10,2,4],[],7,6,[]],[4],[]]
174
+
175
+[[0,1,9,[[8,0],[9],[4,0,4,5,1],[4,10,0,6,2],[9,0,0,8]],9],[9,[0,[8,10,7],10,1,8],[7],[0,5,[10,4],8,[]]]]
176
+[[0,9,8],[5,8],[0,[2,8],6,[],[[8]]],[[[1,8,4,4]]],[]]
177
+
178
+[[[[0,7],10],[[1,10,4],[2,9,2],[9,9,3,6]],5,4,6],[[7],9],[[],[],[[0]],2]]
179
+[[[[],5,10,3],[0,7,2,1,[9,1]]],[],[[[8,5]],[[1,5,1,7,2],[8,6,1,7,9]],2,7],[]]
180
+
181
+[[[6,[9,5],[3,8,5,2],1],[[9,0,6,0,4],10],[[6,8],[6,6,6,8],6,[],0],0,7],[0,5,2,[[6,10,2,4]]],[[7]]]
182
+[[2,[2,[]],[[3,9,1,4,3],4,9,[5,0,6]]],[9,[[6,10,6]]],[10,[10],[0,5,[6,9,2,4,6],[8,6,6],[4,4,7,0,10]]],[5,[]]]
183
+
184
+[[[[]],[],[[8,9,9,10,7]]],[9,[4,[0],[2,2,7,6,7],5,[1,2]],8],[[[7,6],[4,5,6],[5,4,9,2,2]],2,2,2,[[4,3,8,6],[0,10,4,0,0],[7,1,4]]],[[],[9,10,9,[2,6,1,2,5],[5,9,5]]],[[[5,10,10],0]]]
185
+[[[]],[],[]]
186
+
187
+[[[5],5,1,6,[[10,0,5],[6],[5,0,10]]],[],[[8],[[9,0,3,4],0,[4,6,1],[1,1,2,2],7]],[3,7,3,7,0]]
188
+[[[6,5,[2,7,3],3,[]],[[4,1,10,1,10],[]],2],[[[4,5,7,8],7,[6],7,4],[[4,2,3,2]],9,[[9],[],6,7],1]]
189
+
190
+[[[4,[2,4,10],[],10,[10,0,7]],[5,[],10,6,2],[[0,6,7],3,0,9,[5]]],[4],[3,7,2],[[9,0,[2],[4,10,9,4]]]]
191
+[[[6,10,8,[],[3,0,9,3,0]],1,[[],[8],7,[8],[]],[10,1]],[[[2,9],[10]]],[2],[9,[]]]
192
+
193
+[[],[[]],[7,4,8]]
194
+[[[9,[7,6,5,0,4],8,3]]]
195
+
196
+[[[4,3],7,9,4,10],[[9,[3]],5,[6],[[],[4]]],[[9,1,5,[7,0,4],9],[3,8,0,0],[8,3,2,7],3,[6,3]],[]]
197
+[[[[10,3,4],5,4]],[[[1,1,3],[1,4],6],[[8,7,9,6],[4,10],6,[9,6,3],[]],[[8,2],1,8,10,8],6],[[8,[6],5],[[5,3]]],[[1,[9,5],0,[9,7]]]]
198
+
199
+[[[5],2,7,[[],[10,10,0,5]],[]],[[[6,8,5],[1,6,0],6,[10]]],[[[0],[6,8,7,0],[4,8,9,10,8]],[[],[10,6,1,0],3,[4,1],3]],[9,[[],[],3,1],7,[[8,1,10,10,9],[3,8],[2,4,8]],0]]
200
+[[]]
201
+
202
+[[[7,[]],[3,[1,9,1,9,0]],[3]],[]]
203
+[[2,6,[[],3,6]],[7,2,2,[[0,9,5,9],[7],9,6,6],10],[],[8,2,[4,[4,3]],1]]
204
+
205
+[[9,[10,[8,1,0,9],[2,4,6,4,6],[4,4,1]]]]
206
+[[5,3,[[2,0,3],[1,1],[7],7],[[],0],[[0,4,8,3,9],4]]]
207
+
208
+[[[[4],8,3,6,6],[[],6,[6,8,4,7]]],[0,9],[],[[[],4,[8,4],[2,7],[7,1,10]]]]
209
+[[7,8,[[1,5]]],[6,1,7,[8,10,9,[]]],[],[[[2,7,0,8,10]]]]
210
+
211
+[[9,[1,[7,6],10,10],3,[],[[]]],[]]
212
+[[[[0,0],3,[0]],10,6,6],[],[[[2,0,3,8],4,0,3,[8,6,6,5,3]],[7],2,[[9,7],[],2,[0,6]]]]
213
+
214
+[[[5,[0,0,3,7,6]],7,10,5,[[5,4,4,3,10],[4,5,2,0,0],0]],[],[[1,0,4]]]
215
+[[8,[[5],[],5,8,[9,10,4,1,8]],6],[8],[[],9],[],[7,[],[]]]
216
+
217
+[[[8,[8,6,7]],[5,0,9],4,[7,10,6,[1,4,1,1],3],[6,[3,2,8],10,[9,4],[4,3,3,8]]],[],[1,[[9],0,2],9,[6,0,0,4,[1,3,7]],[3]],[]]
218
+[[0,[],6,[8,[0,2],[0,6],[7,4,1]],10],[8,[4,3,[9,10,0,4,7]],0],[[],0,7]]
219
+
220
+[[2,[[],[4],4]]]
221
+[[6,[8,[0,7,0,3],2]],[6]]
222
+
223
+[[[0,0,[0,8,5],[4,2,4]],[7,[2],[0,4,9,5]],7,[[1,1,4,3]]],[],[],[]]
224
+[[[4,[]],6]]
225
+
226
+[[],[[0,10,1]],[[]],[4,[[6,7,6,1]],[3,3,[],7],[[5,6,8,6,8],[8,7],[1]],0]]
227
+[[[5,4,[8,3,7],[2,6]],[]],[],[0],[1,6]]
228
+
229
+[[2,[7],[9,0,1],1],[10,[5,[10,9,2,8],8,[8,0,0,10,3]],3,[[7,5,9]],9]]
230
+[[6,8],[5],[[[3,0],[],1,6],[[3,0]],3,8,[[6,5,1,8,8],1]],[1,8,2,[[]],4]]
231
+
232
+[[[[9,7,2,6,7],6,3],4,[[6,4,9,7,3],4],[10,0,4,[5,2,4,6,3],[6,6,4]],2],[[9,[3,9],[4,2],[5,0]]],[[0,[6,10,7,2],[7,7,3]],5],[0]]
233
+[[[[9,10,9,0],8,[2]]],[9],[1,10,[3,[]],[8,[8,2,6,6],[3,8,4],0]]]
234
+
235
+[[8,3]]
236
+[[6],[3,[5,6,0,10,4],7,[[7,2,2],[]]],[],[3,[1],[2,[]],[9],3],[7]]
237
+
238
+[9,1,9,8,2]
239
+[9,1,9,8]
240
+
241
+[[[10],[8,0,[]],10,[[6,3,8,8]],[9,5]],[0,9],[[10,[2,3,5,4,10],3,[],[0,8,2,4]],[[7,9,4,7],[8,6,0]]]]
242
+[[2,[8,[5,0],2,9,[9,6,4,2,7]],2,[[]]]]
243
+
244
+[[],[7,[9,2,[3,9,2,4],[1,3],[0,10,4,3]],6],[],[[],2,9]]
245
+[[8,10],[1,[[10,8]],[],0,2]]
246
+
247
+[[9,[[],[1,2,2],0,1,[5,4,5]],[0,3,[0,8,4,6,3],[2,5,6,2],[9,5,9,0]]],[2,[6,[],4,9],8,[7]],[5]]
248
+[[[[2,4,6,4,0],[2,9,4]],5,10],[2,[6,10],6,[],[3,2,[6,6],[1,5,10],[]]],[[6],1,5,9],[[7,7,6],[6,[]]],[[7,9,10,[9,3,2],5],[[5,8,1],[4,1,6],[1,5,3,0,9]],2,8,5]]
249
+
250
+[[[[3,0],[10,8,0]],1],[7,[4,[0,5],0,[],[1,0,7,2,8]],[[],[7,5,1,1],[0,8],[7,6],[10]]]]
251
+[[[],8,2]]
252
+
253
+[[7,[[1],[],6,[2]],[[4,5,4,8]],[]],[0,[[1,8,4],10,[2,3,2,3,4]]],[[10,[1,5],[9,3,1,1,6],4,[]],4,9,[[5,9,2,10,10]]],[7,4,[[1,3,9],0,[7]]],[4]]
254
+[[0,7,4,[6],[]],[[0,[0,2],3,[4],[1,1,10,3]],[1,5,9,6,2],10],[[6],[8],[[1,10,3],[7,5,7],1,[5]],[]],[]]
255
+
256
+[[1],[6,[2,0,10],[[8,7],7,[3,9]],[1,[0,8,10,8],9]],[5],[6,[3,1,[10,10,10,9,5],[9],0],0,[[9],[]]]]
257
+[[5]]
258
+
259
+[[10],[]]
260
+[[[1,3,7,6]],[9,9,[0,[10,2],2,9,4],6],[],[[[7,10],[5],4,8,[5]],8,2]]
261
+
262
+[[2,[],2,6],[10,9],[2,8,2]]
263
+[[[[9],3,3],2],[[0,[]],2,3,[[3]],[5,6,3,[4,2,7]]],[10,[8,8],8,5]]
264
+
265
+[[[[8,1,8],[5,8],6,9],7,2,6],[[2],5,[[],[8,8,0,0],4,[1,4,10,10,4]]],[1,10,[9,4,[]],[],9],[6,8,[[10,2,0,10,10],5,4,[2,6],3]],[[6,0,[6,4],3],[[0,4,6],7],2,[6,[]]]]
266
+[[4,[[5,5,0,1],[8,9]],0,[2,[]]],[6,9,[[9,10,6,7]]],[[],8,[],0],[[],[[1]],[],5,[[6,6,0,2,2],[9],9,[7,3,4]]],[[[3,10,4,4],1],[10,[2]],[1,[6],5,8,4],[]]]
267
+
268
+[[],[1,9,[[],6]]]
269
+[[1,[[9,1],[6,3,1],[1,10,9,2],[4]]],[2,3,[2,8,7],3,8],[8,[3,1,[],9,0],[5]],[[0,4],7,[[10,9,1,4,2],0],[[3,1,7],4,[10,8,7],[0]],2],[10,[9,7,[10,3,2,2]],[[10,5,4],[3],[4]]]]
270
+
271
+[[[9,8,8],[0]],[[],2,1,3],[4,[[]],[8,[4,0,6],7,2,[2,1]],[0,8,[5]],[5,9,[],5,6]],[4,[1,[6,7],1],10],[1,[1]]]
272
+[[7,[[2,3,0,5,8],7,[],8,[]]],[[0],0,[[2],[0,0,2],[1,0]],4]]
273
+
274
+[[[[1,8,6],[4,1,6,4],8,[7,7,8],3],[[2,1,1,8],0,10,7,[]]]]
275
+[[[[9,10,7,1],8,0]],[[]],[4,[2,0,[4,2,10,8,0]],[],[[10,9,10,7],5,5,1,0]]]
276
+
277
+[[4,7,7],[],[[0,[10,7,3,8],8,[10,0]]],[[9],0]]
278
+[[[2,[9,7],[4,2,8,5]]],[[[6,7,4],2,1,[4,1,8],[6,10]],[[4,10,6],[6,2]],[],6,[4]],[[3,1],[[5,10],3],[0]]]
279
+
280
+[[[[7,0],1,[0,10,4,0],[8]],0],[],[2],[10,[[0],[10,1,0,4,1],5,10,4],9,7]]
281
+[[[[]],[[],[7],[],[5,5,5],[8,7,1]],3],[[[9],[],3,4,[7,5,2]],[0,[7,8,0,4,8],[2],[8,4]],[]],[7,[1,9,[5,9,0,4],[]],[[7,8,10,5],[10,6,10,9],0,9,6],[6,4,[]]]]
282
+
283
+[[9],[[[9,9,7],0,[1,10,4]],8,[[1,9,4],[4,10,2,4],[5,6,9,9,8]]],[[],[7,[1]],[4,10,1,[],[1]],[[4,10,8,4],[9,4,8,1,0]]],[10,10],[[[0,4,3],[5,8,4,5]],[],[1]]]
284
+[[[1,[],4,[10,1,7,4,0]],7,[[6,8,9,10,9],[4,10,2],[1,5,3,3,10],6],[[5,2,5,9],[8,8,9]]],[[0]],[10,[5,[9,3],2],[],[0,7,[9,10,3,5,9],1,1]]]
285
+
286
+[[7,[],0,[[4],[9,1,10,9,0],[],8],[3,[1,8],7]],[1],[]]
287
+[[1,[3,6],[5,3,0,5,4],5],[[[8,3,1],2,[10],[],7],[1,[4],[6,10,0,8,6]],[[1,10,7,4],8],10],[5,[5,3,6],6,1]]
288
+
289
+[[4,1,6,7,8],[],[4]]
290
+[[[],[1,3,8,7,5],1]]
291
+
292
+[[],[],[[3,[7,2,5,0],5],[4,[3,10,9,4,1],5,6,[7,7,10,0]],7],[9,8]]
293
+[[[],10,2,[[9,9,8],0,[8,2,3,9,1],[5,3,4],1],[2,7,[1,8,0,6],[8,8]]],[[[7],[4,5,7,8],5,7,5],7],[[6],5],[[[3,0,6,4],10],8,[],[9,[]]]]
294
+
295
+[[[],3,[2,[],[8],4,[9,5,9,9,4]],[[],[0]],[1,5,[4]]]]
296
+[[[2,4,1,[3,5,6,2],9],4,[1,1,[],[3,2,7]],4],[[],8,4],[3]]
297
+
298
+[[[[0,6,8],[8,7,7,10,4],[1]],[[2,7,3],3]],[],[]]
299
+[[4,7,4,6,[0]],[[[6,9,2,5,8],6,[7],10],4,1],[[[4,5,5,2,9],6,8,9],[[1,6,4,3]],7,[]],[[[4,4],[3,6],[5,9,7],4,6],2,5,6]]
300
+
301
+[[[0,[9,4]],8,[8,10,8,[8,10,8]],[8,[3,9,6],10]],[[10,[7],8],2],[],[]]
302
+[[1,3,[10]],[4,1],[0],[[0,10,8,6],2,[[7,3]]]]
303
+
304
+[[[0,[0],3,[3]]],[],[7,4]]
305
+[[6,[],9,[[2,10,8,6,2],[6]],[[2,10,0,0,6],7,5,[8,1,10],9]],[[[],[3,1,1,1],[9]],7,1,7,[]],[],[1]]
306
+
307
+[[1,1,[]],[8,2,9,5],[[6,8,[10,6,9],[9,1,4,8],[3,7,0]],[]]]
308
+[[[10,[9,5,9],9],[4,8,0,4,[5,4]],9,[4],0],[[6,[0,2]],10,5],[],[[[1,5]],4,[3,[1,4,4],[7,10,5,6],6,0]],[]]
309
+
310
+[[8,6,[],7],[[],[],3,[[2,4,6]],[[3,9],5,[8],[6]]]]
311
+[[6,[[10,9,9],6,[1,1,8,1]],[[4,6,10,3,1],[4,2,10,1,9],0,1],[[]]],[6,[[1,7,0,8,5],[5,2],[4,8,7,10],[4,4],[4,6,4,10,9]]],[[8],[[6,4,10,8],[3,9,9],[5,4,5],[3,4,10,5,6]],6,[0,[2,5,0,2,0]]]]
312
+
313
+[[8,[4,6,[1],[9,6,3]],[7],10,7],[10,3],[[4,1,[8,4,8,7,2]],1,10]]
314
+[[[[9,7,8],4,[2,6,6],3,7]],[8,0,10,[[1,5,3,6],4,[],[7]]],[[]],[[[7,10]],0,2,8,[[],[7,4,8],6,4]]]
315
+
316
+[[4,[[5,3,9,4,0]],4,[[],[3,9,3,1,1]],10],[[3,[7,3,9]]],[[5]],[[[1,8,4,0],[5,4,5],[10],6,[7,10,9]],10,[3],[5]]]
317
+[[],[8,4,10],[2,3,[10],7],[[[9,1,2],5,6],[],6,6],[[[7,9,10,0,7]]]]
318
+
319
+[[0,6,5,[3]],[9,[],[]],[],[[1,9,[2],8]],[[[3],[7,4,4],[]],[6],[[7,5,2,1],[9,5,8,0],[4,5,10,8,5],9],2]]
320
+[[10,[[2,7],0,[4,10]]],[0],[[],9],[6,[[10,1,5],[0,3,8,0],10,[3,10]],0,5]]
321
+
322
+[[4,7,6,[[10,4,1,8,3],6,[4,4,7],8]],[4]]
323
+[[6,[[5,8,8,10],[7,2],1]],[[[1,10,9],[2,1,8,6],[6,10]],[4,2]],[0,[[1],10,[1,7,4,6],3,2],3,[0,4,[]],[[9],[3,3,5,9],5]],[[5,8,4,[0]]]]
324
+
325
+[1,10,7,0]
326
+[1,10,7,0,7]
327
+
328
+[[[],6,[[8,7,7],[]],[],[[1,0],4,10]],[6,[[6,0,1],[2,5,3,9],[1,3,7]]],[4,7,[4],[[3,7]],7],[[10,9],[9]],[[[7],8,[],[6]],[[4,10,4],[]],1,[0,4,[5,4,1,4,6]],6]]
329
+[[[],[3,7]],[3],[],[[],[[4,2,10],[2,2,2,9],[8,5,0,7]],0],[[[8],[4,10,7,4]]]]
330
+
331
+[[[],[4,3,[8,9,4,2],10],[3,6,5,[]],[]]]
332
+[[6,5],[[8],1],[10,[2,1],0,3],[[[0,3,1,8]],[],0,4,[3,3,6,[5,3,8]]],[[7,[5,10,2,7,5],10],[[0,2,7,4],2,[8,10,10,0,6]],[[5],[],[0],[]],[[9,0,6,9],9,1,[9]]]]
333
+
334
+[[[4],[3,5,9,[]]],[6,10],[9,[[6],[],[2],[2,1]],0,[]]]
335
+[[[1,0,9,10,[9,5,1,2]],[],0,[[6,1,8,9,5]],[[],2,7]],[[10],7,[9,[1,5,8],[8,7],4,3],[2,[5,3,9,8,2],4]],[2,7,[[6,10,6,2,3],6]],[[[9,4,4,8],4,0,[3,7,2,8]],[[],8,[]]]]
336
+
337
+[[4],[[[1,3,2,8,10],[],[0],5,[2,6]],[0,[5,0,10]],[],9,1],[],[[[0],9],[[3,0,8],1],5,[3,[1],[4,3,6]]],[8,1,[0,[4,7,3,0],[3,1,1],5,10],10,6]]
338
+[[[5,9,[7]],9,6,[10]]]
339
+
340
+[[5,[[2,9]],[[6,0,3,10]],3,4],[3,4,8],[9]]
341
+[[3,[],3,8,3],[1,6,[[10,2],[2,4,10]],7,[]],[4],[[],[],4,3,8],[[],3,0,6]]
342
+
343
+[[4],[],[[[1,5,0,10,1],10,5,3,[9,3,7]],[6,4],8],[]]
344
+[[],[0,1,[4,0,3,1],3,5],[10,[[4,9,2,8]]]]
345
+
346
+[[[8,[3,4]],7,[]],[[8,3,4],[7,[5,0,3,3,0],[10,5,6,10],1],[5,1,[8],10,9]]]
347
+[[1],[9,4,[4,[2,1,8,2,6],7,[]],[0,7,4],[]]]
348
+
349
+[[[[1,7],[10,7,2],8],4,[[5,10],3,[6,7,8]],[[0],2,6,8],3],[9,[[4,10,2]]]]
350
+[[[10],7,[[],[],0,1],7,[]],[]]
351
+
352
+[[[2,0,[0,8,10,3]],0,2,[9,0,[0,2,7],[10,2,2],7],[5]],[],[[8,1,10],2],[]]
353
+[[10,7,2,2,[]],[[[2,2,6,2,5]]],[],[9,8,7]]
354
+
355
+[[5,5,[[10,1],[]]]]
356
+[[9,2,3,[8,3,[0]],0],[[[10],[10,8],10],6],[[[1],[7,8,1]],4]]
357
+
358
+[[6,[],6,6],[[]],[1,[[9],9,6]]]
359
+[[[[]]],[3,6,7],[7],[3]]
360
+
361
+[[8,10],[[0,8,4,9,5],[6,4,9,[5,8]],8,[10,[9,9,6,5],[1,7,1,0,10],2,5]],[1,8,[1],8,7],[]]
362
+[[[0,2,3,[8,2,8,1]],[8,8,1,[4,10]],2],[3,8,3,2],[6,2,[],2]]
363
+
364
+[[[[1,2,4],0,7],[4,[8,9,3],[8,3,3,0,3],[6,2]]],[8],[]]
365
+[[],[[[9,2,7,9],[1,4,1],7],[[6,8],5,[6,7]],[6,3,[0,1,3,8,0],[]],[[]],1],[5,5,9,6],[1]]
366
+
367
+[[5,8,[10,5],[6],[]],[[10,6,[0,5],10]],[6,[],[],9,10]]
368
+[[7],[[[6,5,1,5],[5,10,0,5],6,[]],9],[],[5,2,[2,4,[5],1]],[5]]
369
+
370
+[[[4,[0],2,[2],[8,2,9,10,10]],[0]]]
371
+[[4,3,[[5,9,9,9],9,[0,10,5,6],0]],[[2,5,7,[2,10,5,9,9]],3,[10,[4]],9,1],[[[10,9,1,8,3],6,[2,6],[5,6,10,3],7],5,[2,[2,9,0,4],6,0,[5,8,8,1,0]],[[7],[4,3],[10,8,5,0,4],[8,4,4,7],5],1],[[[],[3]],[[9,5,2,1,1],[5,9]]],[3,4,7]]
372
+
373
+[[10,9,10,3,[]]]
374
+[[[[],[8,7,7,5,8],6,[7,7,8],[3,2,5]]],[4,6,[[4,1,0,6],4,[10,8,6,2,1],4]],[],[[[6],[],6],10,10,2],[6,[[1,5,10,5,9],6],[[4],5,[10,10,9]],10,9]]
375
+
376
+[[9,0],[],[[5,[],[4,5]],8]]
377
+[[7,[[1],6,5,4]],[[6,0]]]
378
+
379
+[[[[9,1],[6,5,2,8,8],2,2,7],[[5,3],[8,1,4,9,1]],4],[[2]],[6,4,0,7,3]]
380
+[[[4],[],[0]],[5,[[7,0,5,0,4]],4,8]]
381
+
382
+[[1,[[7],[],5,5,3]]]
383
+[[],[5],[[8,[5,4,8],[]],3,[3,[10,1,2,2],[7],9],5,0]]
384
+
385
+[[3,[1,8],6],[9]]
386
+[[1,[[3,9,7],4,[4],4,[]]],[[8],[[0],4]],[6],[1,10],[[0]]]
387
+
388
+[[1,0,[[7,4,4,8],[],[8,2,3]]],[4,9,0,[[3,3],3]],[3,[]],[1,10,0,9,[3,8,[9]]]]
389
+[[[10,[5,4,2,1],4,[9,3,8,4]]],[[4],1],[]]
390
+
391
+[[4,10,4,1],[[1,10]],[[6,[1,7],[8,0],6],1],[5,[[],[3,4,2]],[]],[9]]
392
+[[[[3,6],[4,4,0,6],6,[4,4,8],[6,8,4,9]],[10],[6,[6,1,6,7]],5]]
393
+
394
+[[[[0,8,1,4],[],7,4,[3]],[5,7,3,[6,6]]],[[[],[4,3,4,0],7,4],[3,[2,4,2],[]],[[4],7],6,[]],[0,[1,5],10,[[6,10,7,3]],[6,[]]]]
395
+[[[[8]],8,2,[[0,7,7,4,1],[7,9],[],[],4]],[[6],[]],[[],9,6]]
396
+
397
+[[[],[0,[4],10,[4,9,10],3],2,4,[]],[7,1,[10,10,5,10,2],7,[0,9,[6,4]]],[[[],5],9,3,7,9]]
398
+[[[[6,1],2,[6,4,10,3]],[10,[],8,4,[0]]]]
399
+
400
+[[[[6,2,7,2],[4],[5,2,0]],[[0,2]],[[3,7,10,8,5],[],[2],4,8],4]]
401
+[[[],[8,[0],7,[5,6,3,7,3]],6],[[],[[6,10],2,[3,1,7,6]],[6,[]],[[]],4],[[0,[1,8,10,2,5]],3,10,[9,9,[],8],10],[6,7,[[4,9,10,8],1,[]],1,[[8,9],[],1]]]
402
+
403
+[[5,[5,[9,6,1,9],[7]],6,[],[]],[10]]
404
+[[[[9,1],[8],[2,6],[10,4,1],[2]]],[10,0,9,[0,[9,2,5,3],7,4,1]],[7,[[1,1,4,1,2],[10,5,6,9,6],[6,9],6,3],[]]]
405
+
406
+[[2,[[4,7,2,8,9],5,4,2,[2]],[[7],[5,6],3,[]]],[9,6,6,[2,2,8,[],[0,3,6,4]],[6,2,8]],[[[2,1],2,[8],[0,5,7,9,10],10],0,[],1,[6,3,10,3,[]]],[[1,9,9],[[10,3,7]],3,[4,[6,3,1],[],[9],6]]]
407
+[[3,2],[],[[],0,[[2,3,9,4],9,[6,6,1]],[[10,5,1,4],4,2,[5]]],[[[1,0,4],[5,4,4,1,2],[1,6],[4,5],[]],[[0,6,3]],[5]],[]]
408
+
409
+[[6],[],[0,[7],[],8,0]]
410
+[[],[[8,[8,0,0,4],9,7,2],[[2],[9],[1,8,5,0],[5,5,7,3]]],[9],[[],[9,10,[5,5,4,7],[5,1,2,0,5]],[[1,0],10,[5,10,1],9],0]]
411
+
412
+[[8,[[3,0,2,2,7],7,7,[0,3,0]]],[[[0,3,4],[9,7,0,4,1],9],[[3,10,10,4]],8,8]]
413
+[[3],[4,6,6,10,[]],[[[7,1,5,10],[5],[10,3],5],6]]
414
+
415
+[[10,8,[[3,6,9],10,0],7,2],[[],[]],[6,[[]],[]]]
416
+[[[[9,10],7,4,0,[6]]],[5]]
417
+
418
+[[1,[]]]
419
+[[[2,8],7,[[10,4],10,[]]],[[[],[2,1],[10,6,2,7],[9]],[[],3,[],[6,4,3,6,3]],[0,[4,8,3,0,5]],8,3],[2,[[5,10,5,0],[6,4,8,4],3,[3,10,5,3],[6,5,3,8,7]],[[10,8,9]]]]
420
+
421
+[[[[],9],2,2,8],[3,[[],[10,1,1,4,2],[0,7,3]],8],[[],[4]],[[[]],9,4,[5,[3,5,4,4],[],8]],[]]
422
+[[6,[8,3,[7],[9,6]]]]
423
+
424
+[[[[],7],9,[],1,[[],10,2,9]],[[[8,1,6,6],0],2,5,5,[[8,6,5,3],1,6,4,0]],[[8],10,[],2],[[10,2,7,5,[10,3]],[[10,10],7]],[7]]
425
+[[10],[5,[1,[0,10,4,4,6],2,[3],7],9],[8,4,6,2]]
426
+
427
+[[],[[3,6],[],0,[0,[1],[4,10],4],[[7]]],[8,[[2,8]],[[5,3,6,7]]]]
428
+[[[8,[1,1,6,7,1]],[],4],[[6,[],[6,7],[5],[5]]],[[[],0],5],[6,10,6,[]]]
429
+
430
+[[[],[5,[9],[10,4],[1],7]],[1,[2,[10,1,9,0,6],5]],[[[2]],[],[[8,1,9,8,8],8,[],6,8]],[[[6,3,6,4,2],1,[4,6,6,10,9],8,[9,7,7,10]],10],[2]]
431
+[[4],[[],7,9,[[0,8,1,2],[9,8],0,[5],8]],[[8,[9,6],3,[5,6]]],[6,[5,[9,10,4,7],4],[],2,6],[[],8,[[7,7]],[6,0,[8]]]]
432
+
433
+[[9],[1,[],2,[[],5,[7,9,2,1],[7],[]],3],[0,[],[[5,1,2,0],0,[10,9,10,6,10],[8,1],5]],[7,[[3,8,9,10],[0,2]],[2,0],9,[[1,3,9,3,9],[6,6,3],[]]],[4]]
434
+[[[6,3,7],9,[[1,3,5,8,10],1,[6,10,10,9],3,[1,7]]]]
435
+
436
+[[],[[],5]]
437
+[[8],[7,2,10]]
438
+
439
+[[6,[4,[3],[],[1,7,4,2,5],[3,10,10]],8,[],[9,8,[]]],[[0,0,3],[5,[5,2,5],4,[5,1,2,8,6],9],4],[[]]]
440
+[[1,10],[4],[[0],3,[[8],5,[2,6,10,3]]]]
441
+
442
+[[],[8,5,9],[[[5],[3]],7,4,4],[8]]
443
+[[],[]]
444
+
445
+[[8,[],0]]
446
+[[4,4,6],[9,5,[[3,8,4,5],5],9,[[5,3],[0,4,0,3],3,[4,10],7]]]
447
+
448
+[[[[6,2,3,9,9],[4,1],10,[],3],[4,1,[8,5,5,8],[6,7,2],[4]]],[[[10,4,2,10,9],[2],[2,4,6],3],[[0,8,10],[4],[0,7,0,9,0]],[3]],[4,7,3,8]]
449
+[[[6,5,0],9,5,7,2],[[[],[],7,3,0]],[[7],[],4],[1,6,6,[],9]]

+ 96
- 0
ressources/day13.py ファイルの表示

@@ -0,0 +1,96 @@
1
+import json
2
+import pathlib
3
+import sys
4
+
5
+
6
+def parse(puzzle_input: str) -> list[list[int, ...]]:
7
+    """Convert str representations of lists into real int lists"""
8
+    str_pkts: list[list[str, str]] = [
9
+        packet.splitlines() for packet in puzzle_input.split("\n\n")
10
+    ]
11
+    int_pkts: list[list[int, ...]] = []
12
+    for pkt in str_pkts:
13
+        int_pk: list[int, ...] = []
14
+        for pk in pkt:
15
+            # Here's the magick - I'm highly averse to eval()
16
+            int_pk.append(json.loads(pk))
17
+        int_pkts.append(int_pk)
18
+    return int_pkts
19
+
20
+
21
+def compare(l: int, r: int) -> int:
22
+    """Compare 2 ints, return 1, 0, -1 depending on values"""
23
+    if l < r:
24
+        return 1
25
+    elif l > r:
26
+        return -1
27
+    else:
28
+        return 0
29
+
30
+
31
+def compare_packets(left: list[int, ...], right: list[int, ...]) -> int:
32
+    """Compare 2 lists to establish correct order"""
33
+    match left, right:
34
+        case int(), int():
35
+            return compare(left, right)
36
+        case int(), list():
37
+            return compare_packets([left], right)
38
+        case list(), int():
39
+            return compare_packets(left, [right])
40
+        case list(), list():
41
+            for l, r in zip(left, right):
42
+                res = compare_packets(l, r)
43
+                if res != 0:
44
+                    return res
45
+            return compare_packets(len(left), len(right))
46
+
47
+
48
+def part1(pairs: list[list[int, ...]]) -> int:
49
+    """Solve part 1"""
50
+    sum_of_indices: int = 0
51
+    for idx, pair in enumerate(pairs):
52
+        if compare_packets(*pair) == 1:
53
+            sum_of_indices += idx + 1
54
+    return sum_of_indices
55
+
56
+
57
+def flatten(l: list[list[int]]) -> list[int]:
58
+    """Flatten a nested list one level"""
59
+    return [item for sublist in l for item in sublist]
60
+
61
+
62
+def find_index(l: list[list[int]], item: list[int]) -> int:
63
+    """Return index of where item falls in list"""
64
+    item_idx: int = 0
65
+    for pkt in flatten(l):
66
+        if compare_packets(pkt, item) == 1:
67
+            item_idx += 1
68
+    return item_idx
69
+
70
+
71
+def part2(pairs: list[list[int, ...]]) -> int:
72
+    """Solve part 2"""
73
+    # Remove one layer of list to match flattened list above
74
+    first_divider: list[int] = [2]
75
+    second_divider: list[int] = [6]
76
+
77
+    first_pos: int = find_index(pairs, first_divider) + 1
78
+    second_pos: int = find_index(pairs, second_divider) + 2
79
+    return first_pos * second_pos
80
+
81
+
82
+def solve(puzzle_input: str) -> tuple[int, int]:
83
+    """Solve the puzzle for the given input"""
84
+    data: list[list[int, ...]] = parse(puzzle_input)
85
+    solution1: int = part1(data)  # Correct answer was 4734 (with my data)
86
+    solution2: int = part2(data)  # Correct answer was 21836 (with my data)
87
+
88
+    return solution1, solution2
89
+
90
+
91
+if __name__ == "__main__":
92
+    for path in sys.argv[1:]:
93
+        print(f"{path}:")
94
+        puzzle_input = pathlib.Path(path).read_text().strip()
95
+        solutions = solve(puzzle_input)
96
+        print("\n".join(str(solution) for solution in solutions))

+ 117
- 0
src/Day13.hs ファイルの表示

@@ -0,0 +1,117 @@
1
+{-# LANGUAGE BlockArguments #-}
2
+
3
+module Day13 (parsePackets, Packet (..), checkPair, sumIndices, day13, parsePacketList, addDividers, part2, findDividers, dividers) where
4
+
5
+import Text.Megaparsec
6
+import Text.Megaparsec.Char
7
+import Data.Void (Void)
8
+import Control.Monad (void)
9
+import Data.List (intercalate, elemIndex, sort)
10
+import Data.Maybe (catMaybes, mapMaybe)
11
+
12
+data Packet = List [Packet] | Entry Int
13
+
14
+instance Eq Packet where
15
+  (Entry a) == (Entry b)  = a == b
16
+  (List [Entry a]) == (Entry b) = a == b
17
+  (Entry a) == (List [Entry b]) = a == b
18
+  (List []) == (Entry _) = False
19
+  (List []) == (List (_:_)) = False
20
+  (List []) == (List []) = True
21
+  (Entry _) == (List [])  = False
22
+  (List (a:as)) == (List (b:bs)) = a == b && List as == List bs
23
+  a@(Entry _) == b@(List _) = List [a] == b
24
+  a@(List _) == b@(Entry _) = a == List [b]
25
+  (List (_:_)) == (List []) = False
26
+
27
+instance Ord Packet where
28
+  compare (Entry x) (Entry y) = x `compare` y
29
+  compare (List []) (List []) = EQ
30
+  compare (List []) (List (_:_)) = LT
31
+  compare (List ((Entry x):xs)) (List ((Entry y):ys))
32
+    | x < y = LT
33
+    | x == y = List xs `compare` List ys
34
+    | otherwise = GT
35
+  compare (List (x:xs)) (List (y:ys)) =
36
+    case x `compare` y of
37
+      LT -> LT
38
+      EQ -> List xs `compare` List ys
39
+      GT -> GT
40
+  compare (List (_:_)) (List []) = GT
41
+  compare (Entry x) (List ys) = List [Entry x] `compare` List ys
42
+  compare (List xs) (Entry y)=  List xs `compare` List [Entry y]
43
+
44
+
45
+newtype PacketPair = PacketPair (Packet, Packet) deriving (Eq)
46
+
47
+instance Show PacketPair where
48
+  show (PacketPair (p1, p2)) = show p1 ++ "\n" ++ show p2 ++ "\n"
49
+
50
+instance Show Packet where
51
+  show (Entry n) = show n
52
+  show (List ps) = "["  ++ intercalate "," (map show ps) ++ "]"
53
+
54
+type Parser = Parsec Void String
55
+
56
+parsePackets :: String -> [PacketPair]
57
+parsePackets input = case parse (packetPairs `sepBy` eol) "" input of
58
+  Left err -> error (show err)
59
+  Right result -> result
60
+
61
+parsePacketList :: String -> [Packet]
62
+parsePacketList input = case parse (packetLine `sepBy` eol) "" input of
63
+  Left err -> error (show err)
64
+  Right result -> catMaybes result
65
+
66
+packetLine :: Parser (Maybe Packet)
67
+packetLine = Just <$> parsePacket <|> return Nothing
68
+
69
+packetPairs :: Parser PacketPair
70
+packetPairs = do
71
+    p1 <- parsePacket
72
+    void eol
73
+    p2 <- parsePacket
74
+    void eol
75
+    return $ PacketPair (p1, p2)
76
+
77
+parsePacket :: Parser Packet
78
+parsePacket = do
79
+  void $ char '['
80
+  entries <- (parseNum <|> parsePacket) `sepBy` char ','
81
+  void $ char ']'
82
+  return $ List entries
83
+  where
84
+    parseNum = Entry . read <$> some numberChar
85
+
86
+checkPair :: PacketPair -> Bool
87
+checkPair (PacketPair (p1, p2)) = p1 <= p2
88
+
89
+
90
+sumIndices :: [PacketPair] -> Int
91
+sumIndices pairs = sum $ map fst $ filter snd $ zip [1..] $ map checkPair pairs
92
+
93
+
94
+dividers :: [Packet]
95
+dividers = [List [List [Entry 2]], List [List [Entry 6]]]
96
+
97
+addDividers :: [Packet] -> [Packet]
98
+addDividers = (++)  dividers
99
+
100
+-- find the 1-based indices of the dividers
101
+findDividers :: [Packet] -> [Int]
102
+findDividers packets = map (+1) positions
103
+  where
104
+    positions = mapMaybe findIndex dividers
105
+    findIndex x = x `elemIndex` packets
106
+
107
+part2 :: [Packet] -> Int
108
+part2 packets = product $ findDividers $ sort $ addDividers packets
109
+
110
+day13 :: IO ()
111
+day13 = do
112
+  input <- readFile "ressources/day13-input"
113
+  putStrLn "Day13"
114
+  let pairs = parsePackets input
115
+  putStrLn ("Sum of indices: " ++ show (sumIndices pairs))
116
+  let packets = parsePacketList input
117
+  putStrLn ("Decoder key: " ++ show (part2 packets))

+ 2
- 1
src/Lib.hs ファイルの表示

@@ -14,9 +14,10 @@ import Day9 (day9)
14 14
 import Day10 (day10)
15 15
 import Day11 (day11)
16 16
 import Day12 (day12)
17
+import Day13 (day13)
17 18
 
18 19
 days :: [IO ()]
19
-days = [day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12]
20
+days = [day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12, day13]
20 21
 
21 22
 sep :: IO ()
22 23
 sep = putStrLn "---------"

+ 71
- 0
test/Day13Spec.hs ファイルの表示

@@ -0,0 +1,71 @@
1
+{-# LANGUAGE QuasiQuotes #-}
2
+
3
+module Day13Spec (spec) where
4
+
5
+import Day13
6
+import Test.Hspec
7
+import Text.Heredoc
8
+import Data.List (sort, elem, elemIndex)
9
+
10
+testInput :: String
11
+testInput = [str|[1,1,3,1,1]
12
+                |[1,1,5,1,1]
13
+                |
14
+                |[[1],[2,3,4]]
15
+                |[[1],4]
16
+                |
17
+                |[9]
18
+                |[[8,7,6]]
19
+                |
20
+                |[[4,4],4,4]
21
+                |[[4,4],4,4,4]
22
+                |
23
+                |[7,7,7,7]
24
+                |[7,7,7]
25
+                |
26
+                |[]
27
+                |[3]
28
+                |
29
+                |[[[]]]
30
+                |[[]]
31
+                |
32
+                |[1,[2,[3,[4,[5,6,7]]]],8,9]
33
+                |[1,[2,[3,[4,[5,6,0]]]],8,9]
34
+                |]
35
+
36
+falsePositive :: String
37
+falsePositive = "[[],[[[10,2,6],[1,4,9,2,5]],[],[5,2],[1,3,5]],[[[7,2,2,0],[0,1],10],10,[9,[4,8],[8,2,10],[1,4,2]],7,[[2]]]]\n" ++
38
+                "[[],[[[],[],[9,10,5,6],2,[0]],10],[[],[[4,9,3,7],7,4],[],2,2],[8,[6,8,[7,5,5],[2,4,8,0,7],[3,1,7,3,9]],[[9,1,5,1],[5,1,1],[],[2,1,2,1]],[[0,9,1,10],5,[],10,[5,0,10,2]],[10,[3,4,8,8,4],5]]]\n"
39
+
40
+spec :: Spec
41
+spec =
42
+  describe "Day12" $ do
43
+    describe "Part1" $ do
44
+      it "parser a single pair" $ do
45
+        let input = "[1,[],3]\n[]\n"
46
+        show (head $ parsePackets input) `shouldBe` input
47
+      it "checks order" $ do
48
+        Entry 1 <= Entry 2 `shouldBe` True
49
+        Entry 2 <= Entry 1 `shouldBe` False
50
+        List [] <= List [] `shouldBe` True
51
+        List [] <= List [Entry 1] `shouldBe` True
52
+        List [Entry 1] <= List [] `shouldBe` False
53
+        List [Entry 1] <= Entry 2 `shouldBe` True
54
+        List [Entry 2] <= Entry 1 `shouldBe` False
55
+        let pair = head $ parsePackets falsePositive
56
+        checkPair pair `shouldBe` False
57
+      it "checks examples" $ do
58
+        let pairs = parsePackets testInput
59
+        length pairs `shouldBe` 8
60
+        sumIndices pairs `shouldBe` 13
61
+        map checkPair pairs `shouldBe` [True, True, False, True, False, True, False, False]
62
+    describe "Part2" $ do
63
+      it "checks examples" $ do
64
+        let packets = sort $ addDividers $ parsePacketList testInput
65
+        let a = packets !! 9
66
+        let b = head dividers
67
+        a `shouldBe` b
68
+        elem (head dividers) packets `shouldBe` True
69
+        findDividers packets `shouldBe` [10, 14]
70
+
71
+

読み込み中…
キャンセル
保存