aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAn0nSaiko <porfeas12@gmail.com>2022-12-18 23:30:13 +0200
committerAn0nSaiko <porfeas12@gmail.com>2022-12-18 23:30:13 +0200
commit77c9806c3de6ee09130f2c5c2344b4ef054c1433 (patch)
tree61e2d2ef5dbdf0cc8253c1389596a946d886701b
parentDay 17 (diff)
downloadaoc22-77c9806c3de6ee09130f2c5c2344b4ef054c1433.tar.gz
aoc22-77c9806c3de6ee09130f2c5c2344b4ef054c1433.zip
Day 18
-rw-r--r--day16/solution.nim297
-rw-r--r--day18/example.txt13
-rw-r--r--day18/input.txt2165
-rw-r--r--day18/solution.nim83
4 files changed, 2416 insertions, 142 deletions
diff --git a/day16/solution.nim b/day16/solution.nim
index ae93568..66015d3 100644
--- a/day16/solution.nim
+++ b/day16/solution.nim
@@ -5,25 +5,26 @@ import tables
5import strformat 5import strformat
6import algorithm 6import algorithm
7import sets 7import sets
8import sugar
8 9
9type 10type
10 NodeData = tuple 11 NodeData = tuple
11 pressure: int 12 pressure: int
12 neighbors: seq[string] 13 neighbors: seq[int64]
13 14
14 Node = tuple 15 Node = tuple
15 id: string 16 id: int64
16 data: NodeData 17 data: NodeData
17 18
18 NodeGraph = Table[string, NodeData] 19 NodeGraph = Table[int64, NodeData]
19 20
20 ExtendedNodeData = tuple 21 ExtendedNodeData = tuple
21 pressure: int 22 pressure: int
22 neighbors: Table[string, int] 23 neighbors: Table[int64, int]
23 24
24 ExtendedNodeGraph = Table[string, ExtendedNodeData] 25 ExtendedNodeGraph = Table[int64, ExtendedNodeData]
25 26
26proc parseLine(line: string): Node = 27proc parseLine(line: string): auto =
27 let tokens = line.replace("Valve ") 28 let tokens = line.replace("Valve ")
28 .replace("has flow rate=") 29 .replace("has flow rate=")
29 .replace(re"; tunnels? leads? to valves?") 30 .replace(re"; tunnels? leads? to valves?")
@@ -35,145 +36,157 @@ proc parseFile(content: string): NodeGraph =
35 let lines = content.strip().splitLines() 36 let lines = content.strip().splitLines()
36 let nodes = map(lines, parseLine) 37 let nodes = map(lines, parseLine)
37 38
38 for node in nodes: 39 # Create stringID to intID mapping
39 result[node.id] = node.data 40 var nodeIDs: Table[string, int64]
40 41 for i, node in nodes:
41proc bfs(input: NodeGraph, src: string): Table[string, int] = 42 nodeIDs[node[0]] = 1 shl i
42 var q = @[(src, 0)] 43
43 result[src] = 0 44 echo nodeIDs
44 45 # for i, node in nodes:
45 while q.len() > 0: 46 # result[nodeIDs[nodes[0]]] = (node[1][0], map(node[1][1], (stringID) => nodeIDs[stringID]))
46 let (curr, pathLen) = q[0] 47
47 q.delete(0) 48# proc bfs(input: NodeGraph, src: string): Table[string, int] =
48 49# var q = @[(src, 0)]
49 for neighbor in input[curr].neighbors: 50# result[src] = 0
50 if result.contains(neighbor): 51#
51 continue 52# while q.len() > 0:
52 result[neighbor] = pathLen+1 53# let (curr, pathLen) = q[0]
53 q.add((neighbor, pathLen+1)) 54# q.delete(0)
54 55#
55proc setup(input: NodeGraph): ExtendedNodeGraph = 56# for neighbor in input[curr].neighbors:
56 for node in input.keys(): 57# if result.contains(neighbor):
57 # Exclude all 0 pressure nodes except the entry node "AA" 58# continue
58 if (input[node].pressure == 0 and node != "AA"): 59# result[neighbor] = pathLen+1
59 continue 60# q.add((neighbor, pathLen+1))
60 let allConnected = bfs(input, node) 61#
61 var filtConnected: Table[string, int] 62# proc setup(input: NodeGraph): ExtendedNodeGraph =
62 for conn in allConnected.keys(): 63# for node in input.keys():
63 if input[conn].pressure == 0: 64# # Exclude all 0 pressure nodes except the entry node "AA"
64 continue 65# if (input[node].pressure == 0 and node != "AA"):
65 filtConnected[conn] = allConnected[conn] 66# continue
66 67# let allConnected = bfs(input, node)
67 result[node] = (input[node].pressure, filtConnected) 68# var filtConnected: Table[string, int]
68 # echo fmt"{node} : {result[node]}" 69# for conn in allConnected.keys():
69 70# if input[conn].pressure == 0:
70type Agent = tuple 71# continue
71 valv: string 72# filtConnected[conn] = allConnected[conn]
72 time: int 73#
73 74# result[node] = (input[node].pressure, filtConnected)
74# Nodes with their neighbors 75# # echo fmt"{node} : {result[node]}"
75var Graph: ExtendedNodeGraph 76#
76# Node names 77# type Agent = tuple
77var nodes = newSeq[string]() 78# valv: string
78 79# time: int
79proc playing(agent: Agent, time: int): bool = 80#
80 agent.time == time 81# # Nodes with their neighbors
81 82# var Graph: ExtendedNodeGraph
82proc agentScores(agent: Agent, time: int): int = 83# # Node names
83 Graph[agent.valv].pressure * (time-1) 84# var nodes = newSeq[string]()
84 85#
86# proc playing(agent: Agent, time: int): bool =
87# agent.time == time
88#
89# proc agentScores(agent: Agent, time: int): int =
90# Graph[agent.valv].pressure * (time-1)
91#
85# type ValveSet = uint64 92# type ValveSet = uint64
93#
86# proc incl(set: var ValveSet, valve: uint64): void = 94# proc incl(set: var ValveSet, valve: uint64): void =
87# set = set or valve 95# set = set or valve
88 96#
89var part2 = false 97# proc contains(set: ValveSet, valve: uint64): bool =
90proc dfs(visited: HashSet[string], time: int, human, elephant: Agent): int = 98# return (set and valve) > 0
91 # echo fmt"time: {time}, human: {human}, elephant: {elephant}" 99#
92 let remainingValves = nodes.len() - visited.len() 100# var part2 = false
93 if time <= 1 or remainingValves == 0 or (part2 and human.valv == elephant.valv and remainingValves > 1): 101# proc dfs(visited: ValveSet, time: int, human, elephant: Agent): int =
94 return 0 102# # echo fmt"time: {time}, human: {human}, elephant: {elephant}"
95 103# let remainingValves = nodes.len() - visited.len()
96 let 104# if time <= 1 or remainingValves == 0 or (part2 and human.valv == elephant.valv and remainingValves > 1):
97 neighborsHuman = Graph[human.valv].neighbors 105# return 0
98 neighborsElephant = Graph[elephant.valv].neighbors 106#
99 var 107# let
100 # check for race 108# neighborsHuman = Graph[human.valv].neighbors
101 humanScore = if human.valv notin visited: human.agentScores(time) else: 0 109# neighborsElephant = Graph[elephant.valv].neighbors
102 elephantScore = if elephant.valv notin visited: elephant.agentScores(time) else: 0 110# var
103 111# # check for race
104 var bestNextScore = 0 112# humanScore = if human.valv notin visited: human.agentScores(time) else: 0
105 if human.playing(time) and elephant.playing(time): 113# elephantScore = if elephant.valv notin visited: elephant.agentScores(time) else: 0
106 for nextHuman in nodes: 114#
107 for nextElephant in nodes: 115# var bestNextScore = 0
108 if nextHuman in visited or nextElephant in visited: 116# if human.playing(time) and elephant.playing(time):
109 continue 117# for nextHuman in nodes:
110 let 118# for nextElephant in nodes:
111 nextTimeHuman = time - 1 - neighborsHuman[nextHuman] 119# if nextHuman in visited or nextElephant in visited:
112 nextTimeElephant = time - 1 - neighborsElephant[nextElephant] 120# continue
113 nextTime = max(nextTimeHuman, nextTimeElephant) 121# let
114 nextScore = dfs(union(visited, toHashSet(@[elephant.valv, human.valv])), nextTime, (nextHuman, nextTimeHuman), (nextElephant, nextTimeElephant)) 122# nextTimeHuman = time - 1 - neighborsHuman[nextHuman]
115 bestNextScore = max(bestNextScore, nextScore) 123# nextTimeElephant = time - 1 - neighborsElephant[nextElephant]
116 124# nextTime = max(nextTimeHuman, nextTimeElephant)
117 # elephant keeps his score only if he isn't in the same valve as human 125# nextScore = dfs(union(visited, toHashSet(@[elephant.valv, human.valv])), nextTime, (nextHuman, nextTimeHuman), (nextElephant, nextTimeElephant))
118 elephantScore = (if human != elephant: elephantScore else: 0) 126# bestNextScore = max(bestNextScore, nextScore)
119 return bestNextScore + humanScore + elephantScore 127#
120 128# # elephant keeps his score only if he isn't in the same valve as human
121 if human.playing(time): 129# elephantScore = (if human != elephant: elephantScore else: 0)
122 for nextHuman in nodes: 130# return bestNextScore + humanScore + elephantScore
123 if nextHuman in visited: 131#
124 continue 132# if human.playing(time):
125 let 133# for nextHuman in nodes:
126 nextTimeHuman = time - 1 - neighborsHuman[nextHuman] 134# if nextHuman in visited:
127 nextTime = max(nextTimeHuman, elephant.time) 135# continue
128 nextScore = dfs(union(visited, toHashSet(@[human.valv])), nextTime, (nextHuman, nextTimeHuman), elephant) 136# let
129 bestNextScore = max(bestNextScore, nextScore) 137# nextTimeHuman = time - 1 - neighborsHuman[nextHuman]
130 138# nextTime = max(nextTimeHuman, elephant.time)
131 # Check for race 139# nextScore = dfs(union(visited, toHashSet(@[human.valv])), nextTime, (nextHuman, nextTimeHuman), elephant)
132 return bestNextScore + humanScore 140# bestNextScore = max(bestNextScore, nextScore)
133 141#
134 if elephant.playing(time): 142# # Check for race
135 for nextElephant in nodes: 143# return bestNextScore + humanScore
136 if nextElephant in visited: 144#
137 continue 145# if elephant.playing(time):
138 let 146# for nextElephant in nodes:
139 nextTimeElephant = time - 1 - neighborsElephant[nextElephant] 147# if nextElephant in visited:
140 nextTime = max(human.time, nextTimeElephant) 148# continue
141 nextScore = dfs(union(visited, toHashSet(@[elephant.valv])), nextTime, human, (nextElephant, nextTimeElephant)) 149# let
142 bestNextScore = max(bestNextScore, nextScore) 150# nextTimeElephant = time - 1 - neighborsElephant[nextElephant]
143 151# nextTime = max(human.time, nextTimeElephant)
144 # Check for race 152# nextScore = dfs(union(visited, toHashSet(@[elephant.valv])), nextTime, human, (nextElephant, nextTimeElephant))
145 return bestNextScore + elephantScore 153# bestNextScore = max(bestNextScore, nextScore)
146 154#
147 assert(false) 155# # Check for race
148 156# return bestNextScore + elephantScore
149proc solve(initDelays: Table[string, int], time: int): int = 157#
150 158# assert(false)
151 if not part2: 159#
152 for human in nodes: 160# proc solve(initDelays: Table[string, int], time: int): int =
153 let 161#
154 humanStartTime = time - initDelays[human] 162# if not part2:
155 startTime = humanStartTime 163# for human in nodes:
156 result = max(result, dfs(initHashSet[string](), startTime, (human, humanStartTime), (human, -1))) 164# let
157 else: 165# humanStartTime = time - initDelays[human]
158 for i, human in nodes[0 ..< ^1]: 166# startTime = humanStartTime
159 for elephant in nodes[i+1 .. ^1]: 167# result = max(result, dfs(initHashSet[string](), startTime, (human, humanStartTime), (human, -1)))
160 let 168# else:
161 elephantStartTime = time - initDelays[elephant] 169# for i, human in nodes[0 ..< ^1]:
162 humanStartTime = time - initDelays[human] 170# for elephant in nodes[i+1 .. ^1]:
163 startTime = max(elephantStartTime, humanStartTime) 171# let
164 result = max(result, dfs(initHashSet[string](), startTime, (human, humanStartTime), (elephant, elephantStartTime))) 172# elephantStartTime = time - initDelays[elephant]
173# humanStartTime = time - initDelays[human]
174# startTime = max(elephantStartTime, humanStartTime)
175# result = max(result, dfs(initHashSet[string](), startTime, (human, humanStartTime), (elephant, elephantStartTime)))
176#
177#
165 178
166let content = readFile("./example.txt") 179let content = readFile("./example.txt")
167
168let input = parseFile(content) 180let input = parseFile(content)
169Graph = setup(input) 181echo input
170# Table of delays to get from starting node "AA" to current 182
171let initDelays = Graph["AA"].neighbors 183# # Table of delays to get from starting node "AA" to current
172Graph.del("AA") 184# let initDelays = Graph["AA"].neighbors
173 185# Graph.del("AA")
174for node in Graph.keys(): 186#
175 nodes.add(node) 187# for node in Graph.keys():
176 188# nodes.add(node)
177echo solve(initDelays, 30) 189#
178part2 = true 190# echo solve(initDelays, 30)
179echo solve(initDelays, 26) 191# part2 = true
192# echo solve(initDelays, 26)
diff --git a/day18/example.txt b/day18/example.txt
new file mode 100644
index 0000000..73a7202
--- /dev/null
+++ b/day18/example.txt
@@ -0,0 +1,13 @@
12,2,2
21,2,2
33,2,2
42,1,2
52,3,2
62,2,1
72,2,3
82,2,4
92,2,6
101,2,5
113,2,5
122,1,5
132,3,5
diff --git a/day18/input.txt b/day18/input.txt
new file mode 100644
index 0000000..5ea9dff
--- /dev/null
+++ b/day18/input.txt
@@ -0,0 +1,2165 @@
17,2,7
212,2,8
311,18,11
47,6,3
57,7,17
69,15,2
712,17,8
812,8,3
911,6,17
108,18,10
1111,14,3
1216,14,8
1312,5,4
147,4,14
1510,3,15
164,16,7
1714,13,15
1813,17,8
198,17,13
203,14,12
217,17,11
223,15,12
235,12,15
2417,8,10
258,17,9
263,12,11
2716,12,7
2812,4,8
2912,10,1
307,12,17
3115,12,11
329,5,15
339,17,8
348,13,3
358,15,5
365,7,14
379,2,13
383,9,8
3911,4,12
405,10,14
417,8,2
429,3,4
4310,12,2
449,5,16
457,14,16
4614,18,11
476,14,16
484,13,10
496,10,17
509,9,18
5112,4,6
522,8,13
534,6,12
5417,13,7
5516,7,7
568,6,16
5715,6,12
5811,16,12
599,1,8
6013,16,9
6116,13,10
6215,7,4
639,15,16
649,17,6
653,12,6
6612,14,15
6712,1,8
685,8,4
6910,18,11
7012,4,3
7113,12,3
723,5,7
7315,6,6
7416,11,16
754,13,6
763,4,10
7713,12,2
7816,8,6
7912,17,9
809,11,16
819,17,12
8216,10,14
8316,9,6
8414,3,11
859,8,19
8616,6,6
874,3,11
8817,10,5
8917,13,11
9014,15,13
9113,5,4
9216,12,4
9313,15,15
944,4,6
9516,7,14
966,17,8
979,17,9
9813,15,11
9914,16,10
1009,2,7
10117,10,8
10212,9,2
1039,11,18
1049,11,17
10516,6,9
1063,14,8
1074,4,7
1087,15,7
1098,7,17
11010,7,3
11114,10,14
11215,11,16
1137,3,13
11414,10,3
11513,10,2
11612,12,4
1174,8,4
1181,8,9
11911,13,2
12012,6,16
12111,10,17
1221,9,11
1235,16,10
1249,15,5
1253,9,7
1268,11,17
12710,2,10
12816,7,4
12910,18,9
13012,3,11
13110,11,1
13210,2,8
13313,7,15
13411,11,16
1352,13,5
1363,8,9
13714,3,6
13812,10,17
1397,1,10
1408,5,15
14111,15,4
1424,15,11
14312,2,12
1448,9,17
14515,14,6
1467,14,13
1478,4,5
1489,3,12
1494,16,12
1506,3,7
1519,3,13
15216,5,13
15310,1,10
1546,12,15
15511,7,16
1568,10,18
15710,17,7
1583,14,6
1593,8,5
1602,11,8
16113,4,4
1626,4,6
1638,16,13
16412,9,17
1657,12,2
16615,6,5
16715,5,11
16810,8,16
1694,13,7
17015,6,15
1715,12,3
1722,9,13
1732,8,10
17412,3,6
1757,3,14
17612,16,7
17710,17,13
17814,4,5
1795,15,15
18015,9,3
18111,2,12
1825,3,13
1836,15,15
1846,2,8
1859,5,2
1864,6,14
18715,14,8
1888,9,18
1897,5,12
19011,7,1
19110,15,16
1925,16,12
1934,12,14
1949,1,12
1959,1,13
19617,7,6
1974,7,13
19813,15,12
1995,14,13
20016,5,5
20114,7,7
2026,11,3
2038,11,1
2044,8,13
2055,2,8
2068,4,4
20712,3,7
20811,9,17
2094,10,5
2104,11,16
21115,8,14
2128,4,13
21314,8,3
2146,6,5
2158,3,8
21614,16,8
2177,10,1
21814,10,17
21915,11,15
22011,13,5
2215,9,3
22212,7,17
22316,8,16
22417,13,8
22511,9,3
2267,3,8
22717,14,9
22817,11,7
2296,16,11
2303,5,8
23112,5,3
23217,5,6
23314,9,16
2349,16,6
2359,7,2
23614,14,14
23714,15,10
23816,13,12
2398,3,4
24011,6,15
2411,10,11
24214,11,13
2439,17,13
2444,10,4
2459,2,6
24610,5,15
24710,4,16
2488,5,16
2496,14,15
25010,10,15
25113,2,8
2524,5,10
2533,13,7
25417,7,10
25516,12,6
25615,4,13
2577,14,3
2588,6,3
2595,13,13
26014,11,2
2616,4,11
2628,17,8
2635,16,9
26413,7,3
26516,9,14
26615,6,11
2679,14,6
2684,6,15
2693,8,14
27014,17,10
2713,13,11
27218,10,9
27310,16,13
27412,1,7
27514,12,10
27612,14,5
27716,7,13
2784,7,11
2799,9,1
28011,4,3
2816,4,8
2825,16,8
28315,11,6
2846,11,17
2859,15,15
2865,14,14
2878,10,17
2884,16,11
2893,13,4
2903,10,14
2919,5,4
2925,15,14
2936,8,2
2945,3,9
2954,9,5
29615,12,13
29711,16,6
2985,4,5
29911,15,9
30014,6,14
30117,8,7
30218,11,7
30310,4,4
3048,3,9
3054,13,13
3063,3,11
30716,9,5
3083,6,5
3096,13,3
3102,10,11
31111,15,3
31214,2,9
31310,12,18
31411,4,9
3155,13,14
3166,15,5
3177,15,14
3185,4,13
3191,7,9
3203,9,14
32111,11,17
32210,16,9
3237,17,9
3249,2,11
3258,8,2
32616,9,4
3273,6,7
3289,6,3
3295,12,16
33014,9,3
33112,13,2
33215,6,7
3337,5,3
33415,3,10
3357,2,9
33611,15,5
33715,16,10
33815,11,13
33910,4,5
34011,5,15
3411,13,7
34217,11,6
3437,13,15
34410,3,4
3458,1,9
3465,5,11
34717,8,6
3489,1,7
3499,2,12
35016,7,12
3519,12,18
35217,6,10
35314,7,8
3546,15,12
35513,9,17
35614,17,11
35713,7,4
35815,3,11
35911,5,16
36014,10,15
36111,0,10
3628,14,4
36312,14,7
36414,17,12
36513,13,13
3666,4,9
3675,16,15
36810,1,12
36910,9,18
37011,3,7
37117,10,14
3723,11,13
37315,4,6
3749,3,11
3755,10,4
37612,14,16
3773,10,13
3789,12,3
3796,16,13
3806,8,3
3815,4,8
3825,3,5
38315,13,9
38414,14,15
38513,13,3
3868,16,11
3875,11,5
3885,17,7
3895,5,7
39013,16,8
39118,12,11
39210,4,15
3936,14,6
3944,15,7
3957,5,4
39614,4,7
39716,12,9
39813,11,17
3992,9,8
4009,1,10
40111,5,3
40214,3,7
40311,14,13
40414,11,3
4052,11,11
4062,8,8
40714,8,16
40815,13,5
4095,7,2
41010,8,17
41111,6,2
4126,12,17
41314,6,5
4146,13,4
41510,18,7
41612,3,14
4172,10,12
4184,4,8
4195,8,14
4209,14,4
4214,5,8
4229,13,18
4233,11,6
42410,10,1
42513,5,15
42610,7,1
42714,9,4
42816,10,5
42915,4,12
43012,9,16
4312,10,10
43211,17,7
43315,9,4
43416,13,14
43515,8,5
4364,14,15
4376,3,10
4386,17,6
4395,11,3
4406,10,2
44110,7,17
44211,10,18
44312,7,16
44413,4,5
44513,15,9
44614,10,4
44716,4,8
4484,9,4
44914,8,15
45010,13,2
4518,11,3
4526,2,10
4538,8,16
4547,17,6
4551,8,11
45613,6,4
45710,3,14
45817,9,13
45916,5,9
46014,11,16
4613,5,14
46217,11,13
4632,9,12
4641,10,10
46516,7,11
4667,5,5
4679,13,5
46811,4,6
4692,7,13
47012,17,7
4717,3,7
47216,5,11
4739,12,1
4743,12,5
47516,5,6
47613,3,12
4777,14,4
4788,2,13
47912,16,14
48015,4,7
48115,15,11
4829,6,4
4833,9,15
4848,2,10
48515,4,10
4869,17,7
4874,4,9
4887,12,4
48911,16,13
4902,12,7
49111,10,2
4928,4,6
49311,2,11
4946,4,14
4959,16,4
49611,1,9
49711,9,1
49815,14,11
4994,6,4
50015,5,8
50116,14,7
50215,12,14
50315,4,11
50415,10,3
50513,12,17
5068,15,4
5076,5,14
5088,4,15
5091,8,8
51013,8,2
51110,16,15
51214,12,16
51315,16,9
51411,15,12
51516,8,7
51614,14,12
5175,8,2
51810,7,16
5195,17,10
5202,6,10
5218,14,17
52213,11,14
5236,10,16
52417,8,8
5256,9,3
52612,13,16
52713,3,10
5288,3,6
5296,7,17
5303,7,6
53112,2,9
53214,5,14
53313,6,16
5347,3,11
5352,12,9
5366,8,17
53714,15,12
53816,10,4
53917,5,12
54011,8,16
5413,13,9
5427,1,6
5439,7,18
5444,7,15
5455,15,4
54616,5,8
54712,16,5
5483,3,8
54913,17,9
5507,17,13
55116,8,5
5524,14,12
55314,4,6
5549,15,13
55510,3,13
5565,15,10
55716,14,9
5587,11,2
5597,12,6
5605,17,12
5613,15,9
5625,2,7
5633,8,13
5648,8,1
5653,14,7
5668,16,5
5673,7,9
5687,5,16
56912,14,3
57014,12,4
5714,2,9
5727,4,13
57317,6,7
5748,8,17
57513,16,6
57612,12,17
5775,8,15
57810,1,8
5799,10,2
5805,15,8
58112,2,7
58214,16,11
5834,6,13
58418,10,11
58515,12,5
58613,14,14
5875,3,8
5884,7,12
58913,18,10
5903,8,11
5917,12,16
5924,13,4
5935,3,7
59412,5,14
59510,2,12
59612,9,3
59710,13,3
59815,8,15
5994,8,15
60013,2,9
60114,17,7
60218,10,12
60312,5,5
60415,3,7
6058,3,14
60610,15,4
60711,7,4
6081,10,13
6096,6,4
6105,10,3
61118,11,11
6124,6,3
6137,5,15
6148,3,13
6158,10,3
6167,4,5
6178,17,10
61811,5,12
6194,5,16
6206,9,4
62115,7,3
62218,11,10
6239,6,17
62416,11,14
6257,8,17
62614,6,15
62713,12,16
6286,5,5
6296,9,15
63013,13,16
63116,13,7
63214,2,6
63316,5,7
63411,10,1
63518,8,11
6362,8,11
63717,14,11
6383,10,12
63913,7,17
64010,7,18
6415,10,17
64217,9,14
6435,7,16
64412,4,14
6459,13,16
64617,9,11
6471,9,13
6482,6,7
64913,15,16
65015,5,14
65112,16,8
65215,10,16
6537,7,16
65411,15,16
65516,10,12
6566,3,13
6572,12,11
65812,16,6
65911,5,4
66010,12,17
66117,6,15
6622,6,12
66312,7,5
6648,3,10
66512,5,16
6666,17,13
66714,4,4
6689,18,8
6695,16,13
6702,11,6
6716,16,7
6728,4,14
67311,12,2
6746,4,5
67514,8,4
6766,1,10
67712,4,16
6789,4,3
67918,8,10
68016,15,10
6815,9,16
68217,10,9
68317,7,9
6847,7,4
6853,10,5
6866,13,15
68711,16,10
6886,6,15
6899,14,17
6904,8,6
6914,4,12
6929,3,3
6937,16,12
69410,14,16
6954,15,6
69616,4,7
6978,6,2
6988,6,17
69916,13,13
70015,15,7
70118,8,8
70212,13,4
70314,13,4
7045,12,4
70515,12,15
7064,4,15
7075,8,17
70817,11,14
70913,16,13
7105,7,7
7118,13,16
7128,5,14
71316,15,8
7146,1,9
71511,18,7
71611,5,2
7179,4,4
7189,13,2
7197,17,7
7206,7,2
72117,10,6
72214,8,2
7237,16,6
72417,9,10
72516,14,6
7267,16,10
7277,3,10
72816,11,13
7296,13,16
7303,8,4
73112,15,5
73217,6,12
73318,9,11
73414,13,5
73515,8,16
73613,14,15
73717,8,13
7385,14,3
7398,13,17
74014,15,9
7418,14,16
74211,12,18
74315,5,10
74410,14,15
74514,7,15
74613,6,3
7473,14,9
74815,17,11
7491,12,9
75011,15,14
7516,16,6
75212,9,14
75311,18,10
75410,13,4
75513,17,11
7565,13,6
75710,1,7
75815,12,6
75912,12,15
7604,6,6
7613,5,13
76211,17,10
7635,14,8
7645,3,10
76513,13,17
7665,13,5
76715,5,12
7685,6,4
76912,15,14
77016,12,12
77112,17,10
77210,13,17
7738,13,1
77415,10,9
77517,13,9
77610,11,16
7778,12,17
7781,13,8
77913,8,3
7805,10,5
78114,5,15
7827,16,8
7837,9,15
78411,17,14
78512,17,11
7867,17,8
78713,10,17
7884,11,15
7893,11,8
7905,5,15
79111,9,18
7923,13,5
79311,14,4
79410,16,12
7957,3,4
7964,7,16
7978,15,16
7982,6,9
7992,13,7
80013,14,3
8016,9,18
8029,7,16
80313,15,13
8047,2,13
8055,11,4
8066,15,14
80718,11,8
8085,6,16
80912,17,5
8109,8,18
8117,4,11
81213,3,7
8137,11,18
81412,3,5
81515,12,4
8166,7,4
81714,13,12
81815,5,15
8199,17,10
8203,15,10
82117,10,11
8229,3,10
8239,13,15
8245,9,4
82516,9,7
8264,11,4
8275,15,16
82817,7,12
82912,6,3
83015,11,4
83113,6,5
8329,3,7
8338,8,18
83413,7,16
83513,16,12
83615,14,7
8376,6,2
83815,9,16
8395,4,6
8402,8,7
84113,17,12
8425,13,4
84311,15,15
84411,2,7
84516,11,9
8466,7,5
8479,9,17
8488,10,1
8499,14,3
85011,5,5
85114,9,5
8525,6,3
85310,2,11
8547,11,15
85516,14,10
8568,1,11
85716,6,13
85812,3,10
85912,4,10
8604,3,10
8619,11,2
8623,13,6
8635,16,7
86411,11,15
8657,17,10
86616,14,11
86716,14,12
8682,5,8
8693,6,10
87010,8,18
8717,4,6
8726,12,3
87315,15,6
8747,3,12
8759,1,9
8765,11,2
87715,5,6
87811,1,12
87917,9,8
88010,18,10
8812,7,11
8826,9,17
8836,12,4
88416,8,11
88515,5,13
8863,10,8
88716,11,12
8888,3,7
8897,2,10
8904,11,5
89116,13,6
8922,11,12
8934,15,9
8947,16,5
8953,11,12
89614,16,9
8972,10,13
8985,12,5
89916,6,11
9005,7,3
90113,11,3
9025,3,11
90314,14,7
9046,5,16
9055,11,17
90611,3,3
9079,10,18
90814,11,15
90912,5,15
9107,4,15
91116,10,10
9128,2,9
91314,6,17
91410,3,3
9155,14,11
91611,12,16
91714,5,9
91810,9,1
91910,3,10
9202,9,10
9217,3,6
92212,6,15
9239,18,9
9243,8,15
9253,4,11
92613,17,13
9275,5,14
9286,11,16
9295,4,9
9307,13,17
93114,6,3
9321,11,6
9335,11,14
93414,15,7
9353,11,14
9367,11,1
93716,8,12
9382,9,14
93913,5,2
9408,2,12
9414,4,11
94213,12,6
9438,6,15
94413,8,1
94517,12,6
94613,5,12
94716,9,8
9486,12,16
94913,7,1
9507,17,12
9515,13,7
95214,7,5
95310,2,7
95411,14,5
95511,16,11
9562,11,7
9579,18,7
95813,15,14
9598,2,14
96015,12,16
96110,7,2
9625,15,6
9637,13,3
9644,5,5
96518,11,9
9667,9,3
9670,10,10
96810,10,17
96916,10,11
9707,9,2
9713,7,8
9729,16,13
97311,13,3
97413,10,3
9759,5,17
97614,8,17
97711,1,8
97816,9,9
97915,6,13
98011,11,2
98110,16,11
9821,11,9
9830,11,9
98415,6,10
9851,5,10
9868,18,11
9877,15,15
9885,17,9
9895,5,4
99010,14,17
9919,6,14
9922,14,9
9936,16,10
99417,14,10
99510,2,5
9966,8,4
9979,18,12
9984,13,12
9994,5,6
100016,6,14
10013,9,11
100216,4,10
100313,5,14
10049,16,8
100514,4,14
100613,14,5
10075,5,6
10087,19,10
10097,6,16
10106,16,9
10118,13,2
10124,12,3
101317,7,8
10144,9,13
10153,5,6
101610,14,3
10174,14,9
10185,4,11
10195,2,9
102010,17,5
10215,10,15
10222,7,8
10233,5,5
10246,17,12
10259,16,11
102616,8,15
10273,5,11
10282,10,9
10299,9,2
10306,6,16
103113,14,12
103210,8,3
103311,6,16
10345,8,3
10353,6,8
103616,8,14
103711,3,4
103811,1,10
10396,12,2
10408,1,6
10415,6,15
10426,14,5
104317,15,10
10447,16,13
104511,2,5
104611,17,5
104715,13,7
104815,15,10
10495,11,16
105012,3,12
10512,12,8
10529,1,6
105311,5,14
105417,8,5
10557,14,15
105617,13,12
10579,15,14
105816,11,6
10598,11,2
10604,16,10
106114,17,9
10624,14,8
10639,18,11
10649,16,14
106510,15,12
106615,13,13
106717,9,7
106813,14,13
10691,12,11
107013,13,15
107113,15,8
10729,16,5
107311,12,17
107416,2,10
107517,12,12
107614,16,12
107710,17,12
10782,14,7
10797,10,2
10804,4,10
10816,16,4
108212,3,8
10836,7,3
108414,3,12
108513,2,10
108613,8,18
10874,5,7
108812,17,14
108914,11,14
109013,18,9
10919,11,1
10926,14,8
109311,8,2
10944,10,16
109516,13,11
109613,8,4
109710,6,17
109814,5,8
10996,8,16
110014,3,5
110114,16,7
110216,11,7
110313,4,11
11042,6,11
11052,10,7
110614,10,6
110710,11,2
11084,12,4
110916,13,8
111015,7,15
11114,9,3
11121,9,9
111316,5,10
111415,11,14
111514,13,14
11167,18,11
11177,3,15
111812,6,4
111916,7,15
112018,13,11
11219,4,15
11222,5,11
11239,2,9
112410,16,14
112511,2,8
112615,8,13
11273,10,6
112817,9,12
11293,10,9
113016,11,15
113111,5,17
113217,8,9
11335,4,10
113416,12,15
113512,2,11
11368,14,13
113714,4,12
113813,4,14
113915,8,6
11407,10,17
114117,12,8
114212,15,6
11433,7,7
114415,9,14
11453,5,10
11466,5,4
114710,8,2
114810,15,15
11497,1,7
11502,7,9
115118,7,9
115212,6,17
11536,16,12
11549,17,11
11556,6,3
11568,1,10
11576,16,5
11584,2,10
11593,10,4
11601,11,11
11615,11,10
116214,13,3
11638,7,2
11642,5,12
11653,11,10
11664,12,13
11674,6,11
11685,3,12
116912,16,11
11702,9,6
11717,2,12
11728,15,3
11733,12,12
11744,15,12
11756,7,16
11764,2,8
117715,7,16
11783,8,8
117913,17,6
118017,9,9
11813,12,14
11829,5,3
11838,8,3
11843,6,9
118511,7,17
118613,11,2
11877,12,3
118813,5,5
118915,10,5
119013,9,2
11919,6,15
119215,14,10
11938,18,6
11945,6,14
11959,14,14
11963,11,11
11979,11,3
11987,7,2
119916,9,10
120012,13,17
120111,3,10
120212,10,3
120316,5,14
12047,9,17
12054,10,13
12068,6,1
120712,15,15
12084,12,12
12093,12,7
121011,10,15
12118,5,18
12127,4,3
121316,12,10
121416,7,8
121512,1,9
12161,11,10
121716,8,9
12186,10,15
121916,12,5
12208,12,16
122114,13,7
12229,4,6
122317,9,6
122414,15,11
122513,11,16
12266,15,7
12272,7,12
122816,15,11
122911,2,13
123012,17,13
12314,13,11
12327,11,3
12339,4,5
123415,16,8
12352,14,11
12364,14,5
123714,6,4
123811,17,9
12395,6,12
12403,11,15
12414,3,9
124212,4,5
12434,12,16
12445,5,5
12458,13,15
124613,3,5
12476,10,3
124818,7,12
124915,8,4
12504,5,13
12515,8,16
125213,14,6
125317,5,9
12545,10,16
125512,18,8
12568,2,11
125713,2,7
12586,2,9
125911,4,15
12604,12,6
126113,5,3
12626,2,12
126311,4,4
126415,10,15
12653,7,5
126615,4,9
12673,11,7
12685,15,7
12695,14,5
127012,17,6
127116,6,10
127212,4,12
127314,11,5
12749,10,17
127513,16,11
12768,7,16
127710,17,4
12782,11,9
127918,9,7
12807,16,15
12812,10,14
128218,8,7
128317,11,9
12845,14,6
12858,3,11
12864,7,14
12872,9,11
128813,15,4
12898,17,6
12907,10,3
12919,9,15
12926,14,17
12932,5,10
129412,13,3
12953,15,7
129616,8,8
12978,3,5
12984,4,13
129912,15,13
130018,12,10
13019,3,14
13024,15,13
130313,15,5
130414,12,6
130516,11,11
130615,6,9
13077,6,17
130817,11,12
13096,18,8
131013,3,13
131113,2,6
131215,14,12
131312,15,3
13142,12,5
13153,4,9
13165,13,15
131714,15,5
13189,7,1
13192,9,7
132010,17,8
13214,7,4
132214,14,4
132311,15,6
13246,9,2
132512,12,3
132614,7,4
132710,6,1
132815,13,14
132911,3,13
13305,4,12
133115,6,4
13329,1,11
133315,17,8
13345,14,10
133511,14,16
133616,8,13
133716,10,13
13389,3,5
133914,12,14
134012,8,2
13413,7,13
134215,4,8
13432,14,5
134410,7,15
13456,12,13
13467,8,3
134710,15,5
13485,15,12
13498,14,5
13501,8,10
13518,16,7
13529,2,4
135315,5,7
13545,15,11
135514,4,13
135610,18,13
135713,12,5
13585,12,12
13594,5,14
136017,8,14
136112,11,2
136214,3,10
136313,7,5
13646,14,13
13653,10,15
136616,7,5
136710,15,14
13686,3,6
136912,17,12
137013,2,11
137115,4,5
13722,7,7
137312,16,12
13749,8,17
137517,11,10
13764,10,14
137712,12,2
13784,6,7
137914,5,12
13803,6,13
138114,8,14
13822,7,10
138316,9,11
138411,1,11
13859,4,16
13868,16,8
138710,2,6
138811,13,17
13896,14,14
139015,14,9
13914,12,10
13928,7,15
13933,6,6
13944,3,8
139513,5,10
13967,7,3
13974,16,9
13985,7,6
13995,12,14
140014,16,6
140116,11,5
14029,4,9
14031,7,13
14049,3,16
140511,3,11
140615,14,14
14074,14,11
14083,13,13
140918,9,9
14109,0,9
14112,6,8
141212,12,1
141317,12,14
141416,14,15
14153,12,4
141612,4,11
141714,15,6
14187,6,2
141910,14,4
14208,12,2
142112,8,17
14225,12,6
14239,3,8
142416,7,6
14256,11,15
142613,9,16
142711,4,16
142816,11,8
142912,15,8
14301,7,11
14315,9,5
143211,2,6
14338,18,9
14348,3,15
143510,17,11
143618,11,12
143714,4,8
143813,14,11
143913,5,7
144011,14,14
14414,15,8
144212,13,6
144312,12,18
144415,6,14
14455,5,13
144615,16,11
14479,7,17
14484,10,15
144914,15,14
14506,15,6
14519,15,3
145212,7,2
145311,16,14
14545,7,15
145517,8,12
14564,5,11
145713,6,7
14585,2,10
145914,3,8
14604,6,5
146117,11,11
14623,14,10
14636,3,9
146414,7,3
146510,5,2
146613,5,16
146715,16,13
146817,6,11
14698,17,15
147013,6,14
147118,7,10
14724,14,14
147313,14,4
14748,17,14
147517,12,9
147610,15,6
147716,9,15
147816,13,5
147911,17,11
148015,5,16
14814,15,10
14829,3,15
14834,8,14
14845,14,9
148511,8,18
148615,10,14
148712,14,14
14884,8,10
148911,7,2
14905,4,7
149115,15,12
14927,8,15
149310,6,16
14947,16,9
149514,4,9
14966,16,8
14978,12,3
149813,3,14
14994,7,3
150013,11,18
150117,10,7
15022,14,10
15035,9,15
150411,4,13
15052,9,9
150610,8,1
150712,15,12
15084,13,14
15098,9,0
151011,18,8
151111,17,12
15123,6,11
15134,13,15
151417,12,10
151511,2,9
151615,3,8
15177,5,14
15182,12,10
151911,7,18
152012,13,15
152112,7,1
15223,13,15
152316,9,13
15243,3,9
152510,7,0
15264,12,5
152717,10,10
152813,13,14
152910,11,18
15307,3,9
153115,15,13
15323,11,4
153315,7,13
15349,4,14
15351,9,7
153615,9,17
15378,11,16
15382,10,6
15394,11,3
154013,15,7
154110,1,11
154210,17,6
15435,13,3
15441,11,7
154511,13,16
154616,10,15
15478,2,6
154810,10,3
154911,2,4
15505,14,12
15517,15,13
15529,3,6
15537,15,4
15547,8,4
155510,13,16
155613,3,8
15571,10,9
155815,10,4
155913,6,2
156014,6,11
15617,13,16
15622,11,13
15633,6,12
156417,10,12
15653,9,13
15665,4,14
156710,4,3
156810,3,5
15699,16,7
15702,12,6
157117,6,9
15729,14,16
157311,13,4
15749,10,16
15757,2,11
15768,2,8
15773,14,5
157814,9,14
15791,6,10
158015,10,2
158114,12,5
15826,14,4
15833,7,11
15845,7,4
15858,17,5
158610,5,5
158714,14,11
158814,5,4
15896,4,7
159014,15,8
159112,5,6
159219,8,11
159311,14,2
15949,2,5
15957,1,9
159615,7,12
15978,9,1
159814,4,11
15998,14,15
160018,12,8
160111,16,5
160213,12,15
160316,12,13
16046,15,10
160515,4,14
16067,6,4
16077,2,14
16085,15,9
16098,19,10
161010,6,2
161116,15,9
16128,5,1
16135,4,15
161416,3,8
16154,4,5
16169,13,17
16175,14,7
161814,10,2
16195,15,5
162011,2,10
16213,12,9
16227,9,1
162312,16,3
16248,15,14
16256,5,15
162615,10,8
162717,7,11
16289,16,9
162915,13,15
16308,9,2
16315,12,8
163214,13,16
16336,15,4
163415,7,5
163511,12,3
163616,4,11
163711,9,2
16383,9,9
16391,11,12
16407,11,17
164111,3,12
16428,5,17
164314,5,7
16445,2,14
164513,10,16
16467,2,8
164717,8,11
164812,12,16
164912,1,13
16508,5,2
165116,5,12
165211,9,16
16532,13,8
165413,12,1
16558,16,4
165617,6,6
165715,7,6
16588,16,15
165918,7,8
166013,6,15
16617,2,6
16625,14,15
16638,14,3
166414,12,3
166511,9,19
16664,17,11
166716,14,5
166813,12,4
166918,10,7
16709,10,1
167110,1,9
16723,9,16
16739,12,17
16746,5,3
167511,17,8
167614,7,16
167710,15,3
16783,12,8
167914,12,17
16807,16,14
16813,15,11
168212,16,13
16839,11,0
16845,7,13
16851,8,13
168611,15,13
168716,12,14
168816,12,11
16899,18,10
169016,13,9
169112,6,2
16928,16,12
169315,11,3
16947,9,18
16956,8,5
169613,16,5
16979,8,2
16982,8,4
16994,14,10
170017,12,7
170117,7,7
170217,13,10
17036,13,10
170414,10,5
170516,3,12
17066,7,15
170710,4,13
170817,6,8
17099,11,19
171016,7,10
17119,6,2
17127,14,14
171311,18,9
171415,7,14
17153,16,9
171612,16,10
17176,16,14
171814,6,10
171914,3,9
17204,5,4
172113,5,13
172212,7,15
172312,3,4
172415,8,3
17257,8,18
172614,2,12
172714,14,8
17284,14,7
17298,7,1
17302,4,10
17318,4,7
173215,7,17
173311,16,8
173414,9,17
173518,12,9
17368,15,15
173710,2,14
173811,4,14
173911,16,15
17404,12,7
174112,4,15
17429,7,3
174310,4,14
174414,5,16
174514,7,17
17465,16,11
174715,3,13
174810,5,17
17498,3,12
17505,11,15
17512,7,5
17523,8,6
17538,17,7
175413,3,9
17558,4,16
17569,2,8
17577,10,16
175811,6,4
17596,15,13
176014,8,7
17616,2,11
176215,14,15
176314,14,6
17647,8,1
17652,8,9
176613,4,6
176714,9,12
176814,6,16
176913,3,6
17704,13,5
177114,2,8
177215,15,9
17738,11,18
17747,15,5
177510,11,3
177617,14,8
17778,18,7
17787,13,2
177913,10,1
17802,14,8
178110,11,0
17826,3,12
17833,11,9
17842,6,6
178516,9,16
178611,18,14
17877,15,16
178810,16,4
17898,17,11
179013,13,5
179110,10,18
179210,16,5
179310,14,5
179412,3,3
17951,9,8
17963,5,9
17977,4,4
179813,3,11
17999,2,10
18008,4,11
180113,9,4
18026,4,4
18031,10,6
180412,10,2
18057,16,11
18067,17,5
18072,11,4
18084,11,6
18098,2,5
181013,3,15
18116,2,7
18126,17,11
181310,5,3
18146,15,9
181511,3,9
181613,14,16
181713,4,9
181817,10,13
181912,2,10
18206,17,10
18217,1,8
18224,7,6
182310,3,6
182414,10,16
18252,12,12
18264,8,5
18278,2,7
18289,4,10
182914,11,17
18306,4,12
183115,10,7
183216,6,7
18332,11,10
183411,6,3
18354,11,8
183611,17,6
183711,16,9
18384,5,12
18392,7,4
18403,14,13
18413,13,10
184213,4,13
18436,9,16
184411,7,3
184513,2,13
18469,13,4
184716,10,3
184812,8,16
18498,16,6
185016,6,12
18511,10,7
185216,10,7
18536,9,1
185411,13,15
18556,13,2
185615,9,15
18575,4,3
185816,15,12
18596,15,11
186010,2,13
18615,6,5
186217,13,6
18638,5,3
18642,7,6
186512,2,13
186612,9,18
18675,17,8
18687,9,16
186913,1,8
18705,3,6
18716,3,11
187211,1,7
187312,4,4
187414,7,2
187517,7,14
18768,1,13
187718,7,7
187810,18,8
187917,12,11
18804,10,8
188118,8,12
18821,9,10
18839,8,3
188412,11,17
18854,11,13
18867,18,8
18873,12,13
188815,13,11
18892,12,15
18903,4,6
18911,10,8
189216,6,5
189315,13,16
189414,5,6
189515,13,4
18969,19,8
18976,18,13
18984,9,15
18997,16,7
190012,8,18
190110,16,6
190212,5,13
190314,5,5
19048,5,4
19059,4,2
190617,12,13
19079,12,4
190812,7,4
190911,17,13
191013,4,15
19113,4,8
191214,7,11
19134,10,2
191413,12,13
191515,3,12
191613,10,14
19174,7,5
19185,9,2
191913,9,6
19206,2,6
19219,6,1
19223,3,10
192318,9,8
19244,15,14
192513,11,4
192614,16,14
19278,1,5
192814,13,13
19294,9,2
19309,16,10
193114,12,15
19329,14,15
19336,4,15
193412,5,7
19353,9,6
193615,14,5
19377,1,11
193815,11,5
193911,3,8
194010,9,17
19419,12,2
19425,8,5
19436,17,7
194412,7,3
194510,12,16
19462,11,14
19471,7,10
19484,8,9
194916,16,12
19502,9,5
195113,8,17
19522,8,12
19534,3,13
195416,8,4
19555,16,6
195615,5,9
19577,14,17
195813,13,4
19595,14,4
196012,3,9
196112,11,1
196211,3,14
19636,12,6
196416,9,12
196511,8,6
19669,9,3
196718,6,12
196810,5,4
19699,14,10
197013,4,8
197113,8,16
19724,13,8
19737,17,14
197410,6,18
197516,3,9
19764,11,10
19776,5,2
197814,15,15
19794,3,12
19803,16,10
19818,7,3
19823,13,12
19836,13,5
19849,17,5
19859,16,16
198611,8,17
19872,8,5
19889,6,18
19899,5,5
199016,12,8
199112,15,16
19924,14,13
19937,11,16
199415,14,13
199514,8,5
199612,11,3
19978,8,4
199814,13,8
199913,8,13
200014,14,5
200110,15,13
200214,5,13
200312,10,4
200410,12,3
20058,13,14
20060,8,9
20072,13,11
20081,12,6
200915,13,8
20109,16,15
20113,7,4
201212,10,18
20134,11,14
201410,9,2
20154,12,15
201615,12,10
201714,7,14
20183,10,7
201917,14,5
20202,11,5
202115,3,9
20224,15,5
202312,11,18
20245,1,10
20256,12,14
20264,16,8
202711,15,2
20281,9,12
20293,10,16
203010,10,16
20318,16,14
203217,7,13
203311,14,17
20345,5,3
203516,7,9
20363,14,14
203715,13,12
203813,4,12
203910,9,3
20404,9,16
204115,13,6
20427,3,5
204315,11,7
20447,4,16
20458,4,8
20464,5,3
204712,16,15
20482,12,13
204918,9,12
205011,11,3
205114,2,10
20528,14,2
20539,9,19
205416,10,6
20552,8,14
20565,6,13
20577,5,6
205814,5,10
205913,10,15
20607,7,18
206117,11,8
206212,15,9
20638,10,2
20648,18,8
206515,8,12
20667,15,11
206712,11,4
20687,13,5
206917,11,4
20702,5,9
20719,8,1
20726,15,16
20735,7,5
207412,6,5
20759,17,14
207611,11,18
20779,15,4
207810,17,9
20798,16,10
208017,11,5
208113,8,15
208218,11,13
20833,13,14
208411,11,1
208513,16,7
208615,16,12
20875,5,9
20883,12,15
20893,14,11
20902,7,14
209111,4,5
20926,6,7
209312,1,10
20943,9,4
209513,17,10
20964,17,12
20975,6,2
209813,4,10
20997,15,3
210015,11,12
21014,13,16
21029,12,15
21036,2,14
21043,7,12
210515,9,5
210613,5,6
210710,17,14
21086,15,8
210910,1,13
211017,12,4
21116,3,8
21126,5,7
211314,14,13
211417,15,11
211512,10,16
211618,8,6
211712,10,15
211817,13,14
211911,5,13
212010,3,7
212115,15,8
212212,9,1
21236,11,2
21244,14,6
212510,15,17
21267,18,6
212712,8,5
21286,11,11
212913,16,10
21306,10,18
213116,6,4
213211,6,1
213316,15,7
21346,5,13
21357,5,17
21366,17,9
21378,15,13
213812,1,11
213912,14,17
21409,2,14
21411,6,8
21429,8,16
214313,7,14
21444,14,4
214512,11,15
21461,12,7
21473,9,12
214814,7,6
214910,2,9
215010,16,8
21516,11,4
215218,9,13
21534,8,16
21544,9,17
215514,11,4
215615,16,7
215718,10,10
215818,10,13
215917,5,11
216010,13,18
21614,9,14
21625,4,4
21639,4,17
21641,10,12
21653,15,13
diff --git a/day18/solution.nim b/day18/solution.nim
new file mode 100644
index 0000000..0ef81fb
--- /dev/null
+++ b/day18/solution.nim
@@ -0,0 +1,83 @@
1import strutils
2import sequtils
3import sugar
4import sets
5
6type Cube = tuple
7 x, y, z: int
8
9proc parseLine(line: string): Cube =
10 let tokens = map(line.split(","), (e) => e.parseInt())
11 (tokens[0], tokens[1], tokens[2])
12
13proc parseFile(content: string): seq[Cube] =
14 let lines = content.strip().splitLines()
15 result = map(lines, parseLine)
16
17proc nextTo(A, B: Cube): bool =
18 let
19 dx = abs(A.x - B.x)
20 dy = abs(A.y - B.y)
21 dz = abs(A.z - B.z)
22
23 dx + dy + dz <= 1 and dx <= 1 and dy <= 1 and dz <= 1
24
25proc part1(cubes: seq[Cube]): int =
26 result = 6 * cubes.len()
27 for i, cube in cubes[0 .. ^2]:
28 for other in cubes[i+1 .. ^1]:
29 if cube.nextTo(other):
30 result -= 2
31
32var
33 solid: HashSet[Cube]
34 visited: HashSet[Cube]
35 maxn = 0
36 minn = -1
37
38proc blocksAround(cube: Cube): int =
39 for x in [cube.x-1, cube.x+1]:
40 if (x, cube.y, cube.z) in solid:
41 result += 1
42
43 for y in [cube.y-1, cube.y+1]:
44 if (cube.x, y, cube.z) in solid:
45 result += 1
46
47 for z in [cube.z-1, cube.z+1]:
48 if (cube.x, cube.y, z) in solid:
49 result += 1
50
51proc dfs(curr: Cube): int =
52 let maxp = max([curr.x, curr.y, curr.z])
53 let minp = min([curr.x, curr.y, curr.z])
54 if minp < minn or maxp >= maxn or visited.containsOrIncl(curr):
55 return 0
56
57 # if is air block
58 if curr notin solid:
59 result = blocksAround(curr) +
60 dfs((curr.x+1, curr.y, curr.z)) +
61 dfs((curr.x-1, curr.y, curr.z)) +
62 dfs((curr.x, curr.y+1, curr.z)) +
63 dfs((curr.x, curr.y-1, curr.z)) +
64 dfs((curr.x, curr.y, curr.z+1)) +
65 dfs((curr.x, curr.y, curr.z-1))
66
67
68proc part2(cubes: seq[Cube]): int =
69 # echo cubes
70 for cube in cubes:
71 maxn = max([cube.x, cube.y, cube.z])
72 maxn += 6
73
74 for cube in cubes:
75 solid.incl(cube)
76
77 result = dfs((0,0,0))
78
79let content = readFile("./input.txt")
80let input = parseFile(content)
81
82echo part1(input)
83echo part2(input)