Compare commits
10 Commits
bdbf95b769
...
2ed0ba2108
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ed0ba2108 | ||
|
|
b5160f1f3d | ||
|
|
687f0aad21 | ||
|
|
9eabf64957 | ||
|
|
4ca301c22b | ||
|
|
50f8acaa66 | ||
|
|
b522c7fd11 | ||
|
|
abe76c0d38 | ||
|
|
09ac79e78f | ||
|
|
c2fbb5cb42 |
41
day12/input.txt
Normal file
41
day12/input.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
abccccaaaaaaaaaaaaaccaaaaaaaacccccccccaaaaaaaaccccccccaaacaaacccccccaaaaaaccccccccccccccccccccccaaaacccccccccccacccccccccccccccccccccccccccccccccccccccccccccccaaaa
|
||||
abccccaaaaacaaaaaaccccaaaaaaccccccccccaaaaaaacccccccccaaaaaaacccccaaaaaaaaaacccccccccccccccccccaaaaaacccccccccaaaaaaaaccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abcccaaaaaccaaaaaaccccaaaaaaccccccaacccaaaaaacccccccccaaaaaacccaaaaaaaaaaaaaaacaaccacccccccccccaaaaaaccccccccccaaaaaacccccccccccccccccccccccccccccccccccccccccaaaaa
|
||||
abccccccaaccaaaaaaccaaaaaaaaccccccaaacaaaacaaacccccccaaaaaaaaccaaaaaaaaaaaaaaacaaaaacccccccccccccaaccccccccccccaaaaaaccccccccccccccccccccccccccccacccccccccccaaaaaa
|
||||
abccccccccccaaccaaccaaaaccaacccccccaaaaaaaccccccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccaaaaccccccccccccccccaaaaaaaacccccccccccccccccccccccccccaaccccccccccccccaa
|
||||
abcccccccaaaaacccaaaaaaaacccaaccccaaaaaaccccccccccccaaaaaaaaaaaaaaaacaaaaaaaccaaaaaaccccccaaaaaccccccccccccccaaaaaaaaaaccaccccccccccccccccccccccccaccccccccccccccca
|
||||
abcccccccaaaaacccaaaaaaaaccaaaaccaaaaaaaaccccccccccccccaaacaaaaaaaaacaaaaaacccccaaaacccccaaaaaaccccccccccccccaaaaaaaaaaaaacccccccccccccccllllllccccdccccccccccccccc
|
||||
abccccccaaaaaacccccaaaaccccaaaaacaaaaaaaaccccccccccccccaaacccccaaaccccaaaaaacccaaccccccccaaaaaacccccccccccccccccaaaaaaaaaacccccccccccccklllllllllcddddccaccaaaccccc
|
||||
abccccccaaaaaacccccaaaaaaaaaaaaaaaccaaccccccaacaacccccccaaccccccccccccaaacaacccccccccccccaaaaaacccccccccccccccccaaaaaaaaaacccccccccccckklllppllllcddddddddaaaaccccc
|
||||
abccccccaaaaaaccccaaacaaaaaaaaaaaaccaaccccccaaaaaccccccccccccccccccccccccccccccccccccccccccaaccccccaaccccccccccccaacaaaaaaaccccccccccckklpppppplllmdddddddddacccccc
|
||||
abccccccccaaacccccaacccaccaaaaaaccccccccccccaaaaaaccccccccccccccccccccccccccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccccckkkkppppppplmmmmmmddddddaacccc
|
||||
abccccaaacaaacccccccccccccaaaaaaccccccccccccaaaaaacccccccccccccccccaaaccccccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccccckkkppppuppppmmmmmmmmddeeeacccc
|
||||
abccccaaaaaaacccccccccccccaaaaaacccaccccccccaaaaaacccccccccccccccccaaaacccccccccccccccccccccaaacccaaaacccccccccccaaaacaaaccccccccccckkkpppuuuuuppqqmmmmmmmmeeeacccc
|
||||
abcccccaaaaaaccccccccccccaaaaaaaacaaccccccccccaaaccccccccccccccccccaaaaccccccccccccccccccccaaaaccccccccccccccccccaaaaaaaacccccccccckkkkpppuuuuupqqqqqqqmmmmeeeccccc
|
||||
abcccccaaaaaaaacccccccccccaccccaaaaacccccccccccccccccccccccccccccccaaaccccccccccccccaaaccccaaaacccccccccccccaaccaaaaaaaaccccccccckkkkkrrpuuuxuuuqqqqqqqqmmmmeeccccc
|
||||
abccccaaaaaaaaaccccccccccccccaaaaaacccccccacaacccccccccccccccccccccccccccccccccccccaaaaaacccaaaccccccccccaaaaccaaaaaaacccccccccckkkkrrrrruuuxxuvvvvvvqqqqnnneeccccc
|
||||
abcccaaaaaaaaaaccccccccccccccaaaaaaaacccccaaaaacccccccccccccccaaaaaccccccccccccccccaaaaaaccccccccccccccccaaaaaaaaaaaaacccccccccjjjkrrrrruuuxxxxvvvvvvvqqqnnneeccccc
|
||||
abcaaaaacaaacccccccccccccccccaaaaaaaacccccaaaaaccaacccccccccccaaaaaccccccccccccccccaaaaaccccccccccccccccccaaaaaccaaaaaacccccccjjjrrrrruuuuuxxxyvyyyvvvqqqnneeeccccc
|
||||
abcaaaaacaaaccaaccccccccccccccccaacccccccaaaaaaaaaaaccccccccccaaaaaaccccccccccccccccaaaaaccccccccccccccccaaaaacccaaaaaaaacaaacjjjrrrtttuuxxxxxyyyyyvvvqqnnneeeccccc
|
||||
abaaaaaccaacccaaaccaacccaaccccccaccccccccaaaaaaaaaacccccccccccaaaaaaccccccccccccccccaacaacccccccccccccccccccaacccaaccccaaaaaacjjjrrrtttxxxxxxxyyyyyvvvrrnnneeeccccc
|
||||
SbaaaaacccccccaaaaaaaccaaaacccccccccccccccaaaaaaaaacccccccccccaaaaaaccccccccccccccccccccccccccccccccccccccccccccccaacccaaaaaacjjjrrrtttxxxEzzzzyyyvvvrrnnneeecccccc
|
||||
abcaaaaacccccccaaaaaaccaaaacccccccccccccccaaaaaaaaacccccccccccccaaccccccccccccccccccccccccccccaaccccccccccaaccccacaaaacaaaaaaajjjrrrtttxxxxxyyyyyvvvrrrnnnfffcccccc
|
||||
abcaacccccccaaaaaaaacccaaaaccccccccccccccccaaaaaaaaaaccccccccccccccccccccccccccccccccccccccaaaaaccccccccccaaccccaaaaaaaaaaaaaajjjqqqttttxxxxyyyyyyvvrrrnnnfffcccccc
|
||||
abccccccccccaaaaaaaaaccccccccccccccccccccaaaaaaaaaaaaacccccccccccccccccaacccccccccccccccccccaaaaaccccccaacaaaaaccaaaacaaaaaaaacjjjqqqqttttxxyywyyyywvrrnnnfffcccccc
|
||||
abccccccccccaaaaaaaaaacccccccccccccccccccaaaaaaaaacaaacccccccccccccaaacaacccccccccccccccccccaaaaaccccccaaaaaaaaccaaaaccccaaacccjjjjqqqqtttxwywwwyywwwrrnnnfffcccccc
|
||||
abcccccccccccccaaaaaaacccccccccccccccccccaaaaaaaaaaaaaaaacccccccccccaaaaaccccccccccccccccccaaaaacccaaccccaaaaccccaacaacccaaaccccjjjiqqqtttwwywwwwwwwwrrroofffcccccc
|
||||
abcccccccccccccaaaccccccccccccccccccccccaaaaaaaaaaaaaaaaaccccccccccccaaaaaacccccccccccccccccccaaacaaaccccaaaaaccccccccccccccccccciiiiqqqttwwwwwswwwwrrrroofffcccccc
|
||||
abcccccccccccccaaccccccccccccaaaacccccccaaaaaaaaccaaaaacccccccccccccaaaaaaacccccccccccccccccccaaaaaaacccaaacaacccccaaaaacccccccccciiiqqqttwwwwsssssrrrrroofffaccccc
|
||||
abcccccccccccccccccccccccccccaaaaccccccccacaaacccaaaaaaccccccaaccccaaaaaaccccccccaacaaccccccccaaaaaaccccaaaacacccccaaaaacccccccccciiiqqqtsswsssssssrrrrooofffaccccc
|
||||
abcccccccccccccccccccccccccccaaaaccccccccccaaaccaaaaaaaccccccaaaaccaacaaaccccccccaaaaacccccccccaaaaaaaaccaaacacccccaaaaaacccccccccciiqqqssssssspposrrroooofffaccccc
|
||||
abccccaaacccccccccccccccccccccaaacccccccccccccccaaacaaaccccaaaaaacccccaaaccccccccaaaaaacccccccaaaaaaaaaaaaaaaaaccccaaaaaaccccccaccciiiqqpsssssppppooooooogffaaccccc
|
||||
abccccaaaaaacccaaaccccccccccccccccccccccccccccccccccccaccccaaaaacccccccccccccccccaaaaaaccccccaaaaaaaaaaaaaaaaaaccccaaaaaacccaaaaccciiiqqppppppppppoooooogggfaaacccc
|
||||
abcccaaaaaaacccaaaccccccccccccccccccccccccccccccccccccccccccaaaaaccccccccccccccccaaaaaaccccccaaacaaaccccaaaaaacccccccaacccccaaaaaacciiipppppppphgggggggggggaaaacccc
|
||||
abccaaaaaaaacccaaacaaacccccccccccccccccccccaacccccccccccccccaacaacccccaacccccccccccaaacccccccccccaaacccccaaaaacccccccccccccccaaaaacciiihppppphhhhgggggggggaaccccccc
|
||||
abccaaaaaaacaaaaaaaaaacccccccccccccccccccccaaaccccccacccccccccccccccccaaccccccccccccccccccccccccaaaaccccaaaaaaccccccccccccccaaaaacccciihhhhhhhhhhgggggggccaaccccccc
|
||||
abccccaaaaaaaaaaaaaaacccccccccccccccccccaaaaaaaaccccaaacaaaccccccccccaaaaccaaccccccccaacaacccccaaaaaaacccaacccccccccccccccccaacaaccccchhhhhhhhhaaaacccccccccccccccc
|
||||
abccccaaaaaacaaaaaaaccccccccccccccccccccaaaaaaaaccccaaaaaaaccccccccccaaaaaaaacaccccccaaaaaccccccaaaaacccccccccccccccccccccccccccccccccchhhhhhacaaaaaccccccccccccccc
|
||||
abccccaaccccccaaaaaacccccccccccccaaccccccaaaaaacccccaaaaaaccccccaaaaaaaaaaaaaaaccccccaaaaaacccaaaaaaacccccccccccccccccccccccccccccccccccccaaaaccaaacccccccccccaaaca
|
||||
abccccccccccccaaaaaaaccccccccccccaaccccccaaaaaacccaaaaaaaaccccccaaaaaaaaaaaaaacccccccaaaaaacccaaaaaaaaccccccaaacccccccccccccccccccccccccccaaaaccccccccccccccccaaaaa
|
||||
abccaaacccccccaaacaaacccccccccaaaaaaaacccaaaaaacccaaaaaaaaacccccaaaaaaaaaaaaaacccccccaaaaaccccaaaaaaaaccccccaaaaccccccccccccccccccccccccccaaaccccccccccccccccccaaaa
|
||||
abcaaaacccccccaaccccccccccccccaaaaaaaacccaaccaacccaaaaaaaaaaccccccccaaaaaaacaacccccccccaaaccccccaaacaaccccccaaaacccccccccccccccccccccccccccccccccccccccccccccaaaaaa
|
||||
30
day12/part1.min.py
Normal file
30
day12/part1.min.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
|
||||
lines = np.array([np.array([ord(y) for y in x.strip()]) for x in open("input.txt")])
|
||||
start = tuple(np.array(np.where(lines == ord('S'))).T[0])
|
||||
end = tuple(np.array(np.where(lines == ord('E'))).T[0])
|
||||
|
||||
lines[start] = ord('a')
|
||||
lines[end] = ord('z')
|
||||
lines = lines-ord('a')
|
||||
|
||||
|
||||
open = [(start, None)]
|
||||
closed = dict()
|
||||
while open:
|
||||
n, prev = open.pop(0)
|
||||
if n in closed:
|
||||
continue
|
||||
closed[n] = prev
|
||||
if n == end:
|
||||
path = [n]
|
||||
while path[-1] is not None:
|
||||
path.append(closed[path[-1]][1])
|
||||
print(len(path)-2)
|
||||
break
|
||||
|
||||
for dx, dy in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
|
||||
xn, yn = n[0]+dx, n[1]+dy
|
||||
if 0 <= xn < len(lines) and 0 <= yn < len(lines[0]) and lines[n] + 1 >= lines[xn, yn]:
|
||||
open.append(((xn, yn), n))
|
||||
64
day12/part1.py
Normal file
64
day12/part1.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
import heapq
|
||||
|
||||
import numpy as np
|
||||
|
||||
lines = np.array([np.array([ord(y) for y in x.strip()]) for x in open("input.txt")])
|
||||
start = tuple(np.array(np.where(lines == ord('S'))).T[0])
|
||||
end = tuple(np.array(np.where(lines == ord('E'))).T[0])
|
||||
|
||||
lines[np.where(lines == ord('S'))] = ord('a')
|
||||
lines[np.where(lines == ord('E'))] = ord('z')
|
||||
lines = lines-ord('a')
|
||||
|
||||
def neighbors(n):
|
||||
x, y = n
|
||||
if x > 0 and lines[n] + 1 >= lines[x-1, y]:
|
||||
yield x - 1, y
|
||||
if y > 0 and lines[n] + 1 >= lines[x, y-1]:
|
||||
yield x, y - 1
|
||||
if x+1 < len(lines) and lines[n] + 1 >= lines[x+1, y]:
|
||||
yield x + 1, y
|
||||
if y+1 < len(lines[0]) and lines[n] + 1 >= lines[x, y+1]:
|
||||
yield x, y + 1
|
||||
|
||||
def distance(n1, n2):
|
||||
return 1
|
||||
|
||||
def cost(n):
|
||||
return abs(n[0]-end[0])+abs(n[1]-end[1])
|
||||
|
||||
def is_end(n):
|
||||
return n == end
|
||||
|
||||
|
||||
def find_path(start, end_fnct, neighbors_fnct, heuristic_cost_estimate_fnct, distance_between_fnct):
|
||||
open = [(0, 0, start, None)]
|
||||
closed = dict()
|
||||
while open:
|
||||
_, prio, n, prev = heapq.heappop(open)
|
||||
if n in closed:
|
||||
continue
|
||||
closed[n] = (prio, prev)
|
||||
if end_fnct(n):
|
||||
path = [n]
|
||||
while path[-1] is not None:
|
||||
path.append(closed[path[-1]][1])
|
||||
return path[:-1]
|
||||
|
||||
for neighbor in neighbors_fnct(n):
|
||||
dist = prio + distance_between_fnct(n, neighbor)
|
||||
heuristic = dist + heuristic_cost_estimate_fnct(neighbor)
|
||||
heapq.heappush(open, (heuristic, dist, neighbor, n))
|
||||
return None
|
||||
|
||||
|
||||
path = list(find_path(
|
||||
start,
|
||||
end_fnct=is_end,
|
||||
neighbors_fnct=neighbors,
|
||||
heuristic_cost_estimate_fnct=cost,
|
||||
distance_between_fnct=distance
|
||||
))
|
||||
|
||||
print(len(path)-1)
|
||||
30
day12/part2.min.py
Normal file
30
day12/part2.min.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
|
||||
lines = np.array([np.array([ord(y) for y in x.strip()]) for x in open("input.txt")])
|
||||
start = tuple(np.array(np.where(lines == ord('S'))).T[0])
|
||||
end = tuple(np.array(np.where(lines == ord('E'))).T[0])
|
||||
|
||||
lines[start] = ord('a')
|
||||
lines[end] = ord('z')
|
||||
lines = lines-ord('a')
|
||||
|
||||
|
||||
open = [(0, end, None)]
|
||||
closed = dict()
|
||||
while open:
|
||||
prio, n, prev = open.pop(0)
|
||||
if n in closed:
|
||||
continue
|
||||
closed[n] = (prio, prev)
|
||||
if lines[n] == 0:
|
||||
path = [n]
|
||||
while path[-1] is not None:
|
||||
path.append(closed[path[-1]][1])
|
||||
print(len(path)-2)
|
||||
break
|
||||
|
||||
for dx, dy in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
|
||||
xn, yn = n[0]+dx, n[1]+dy
|
||||
if 0 <= xn < len(lines) and 0 <= yn < len(lines[0]) and lines[n] - 1 <= lines[xn, yn]:
|
||||
open.append((prio+1, (xn, yn), n))
|
||||
64
day12/part2.py
Normal file
64
day12/part2.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
import heapq
|
||||
|
||||
import numpy as np
|
||||
|
||||
lines = np.array([np.array([ord(y) for y in x.strip()]) for x in open("input.txt")])
|
||||
start = tuple(np.array(np.where(lines == ord('S'))).T[0])
|
||||
end = tuple(np.array(np.where(lines == ord('E'))).T[0])
|
||||
|
||||
lines[np.where(lines == ord('S'))] = ord('a')
|
||||
lines[np.where(lines == ord('E'))] = ord('z')
|
||||
lines = lines-ord('a')
|
||||
|
||||
def neighbors(n):
|
||||
x, y = n
|
||||
if x > 0 and lines[n] - 1 <= lines[x-1, y]:
|
||||
yield x - 1, y
|
||||
if y > 0 and lines[n] - 1 <= lines[x, y-1]:
|
||||
yield x, y - 1
|
||||
if x+1 < len(lines) and lines[n] - 1 <= lines[x+1, y]:
|
||||
yield x + 1, y
|
||||
if y+1 < len(lines[0]) and lines[n] - 1 <= lines[x, y+1]:
|
||||
yield x, y + 1
|
||||
|
||||
def distance(n1, n2):
|
||||
return 1
|
||||
|
||||
def cost(n):
|
||||
return lines[n]
|
||||
|
||||
def is_end(n):
|
||||
return lines[n] == 0
|
||||
|
||||
|
||||
def find_path(start, end_fnct, neighbors_fnct, heuristic_cost_estimate_fnct, distance_between_fnct):
|
||||
open = [(0, 0, start, None)]
|
||||
closed = dict()
|
||||
while open:
|
||||
_, prio, n, prev = heapq.heappop(open)
|
||||
if n in closed:
|
||||
continue
|
||||
closed[n] = (prio, prev)
|
||||
if end_fnct(n):
|
||||
path = [n]
|
||||
while path[-1] is not None:
|
||||
path.append(closed[path[-1]][1])
|
||||
return path[:-1]
|
||||
|
||||
for neighbor in neighbors_fnct(n):
|
||||
dist = prio + distance_between_fnct(n, neighbor)
|
||||
heuristic = dist + heuristic_cost_estimate_fnct(neighbor)
|
||||
heapq.heappush(open, (heuristic, dist, neighbor, n))
|
||||
return None
|
||||
|
||||
|
||||
path = list(find_path(
|
||||
end,
|
||||
end_fnct=is_end,
|
||||
neighbors_fnct=neighbors,
|
||||
heuristic_cost_estimate_fnct=cost,
|
||||
distance_between_fnct=distance
|
||||
))
|
||||
|
||||
print(len(path)-1)
|
||||
449
day13/input.txt
Normal file
449
day13/input.txt
Normal file
@@ -0,0 +1,449 @@
|
||||
[[[8,[4,3,4]],[[4,8,4,0,4],[3],10,[10,10,5,5,7]],10],[2,[],6,9]]
|
||||
[[[6],[],[[]],[5,4,6,9]],[[[9,0,10],[7,2,7]],8,9,0,[[2,9,1,3,5],1,[],10,[]]],[9]]
|
||||
|
||||
[[],[[6,8,0,5]]]
|
||||
[[3],[3,[]],[[4]]]
|
||||
|
||||
[[8,[10]],[1,10,[1,[4,3,1,6],[],[5]]],[3,[1]],[1,8,2,[3,4]]]
|
||||
[[1]]
|
||||
|
||||
[[9,[],[]],[7,0,[6,4,7],7],[[[0,1,3]],2,6,5],[10,[9,10,9]]]
|
||||
[[10,[[2],[0]],7,5,[[3,6,10,1,3],[10,6],0,[3,7]]],[[1],[],[[8,8,10,8],[],[6,5,8,3]],[[5,10,7],[1,2,4]]],[[8,2,0],[3,[]]],[],[[0]]]
|
||||
|
||||
[[[[3]],9]]
|
||||
[[],[2],[]]
|
||||
|
||||
[[9,[10]],[[],[],5,3,8],[]]
|
||||
[[[[9,5],[1,5,9,1,8],1]],[[5,[]],[[4,7,0],[3,10],[4,3,8]],[8,[9,0],7,[2,6,6,7],[10,2,5,4,10]],4,5],[10,[0,9],2],[2,[[0,3,2,5,6]],[],0,[5]],[6,3,3,[]]]
|
||||
|
||||
[[[[5],[0,7,4,1,10],[3,10],[3,2,10,10]],[[7,5,10,6,9]],2,[[8,7,0],[1,6]]]]
|
||||
[[[7,7],1,[7,2,1],[1,7,[10,10,4]],10]]
|
||||
|
||||
[[],[7,0,6,[1],[3,6,3,1]]]
|
||||
[[7,10,[0],[],[]],[10,1,1,5,2],[],[0,[],5],[[[2,0,0,1,1],3],[0,[8,0,3,8,6],[1,1,1,8],[2,6,4,6,10],10],[[],10,[0,0,0,3,10]]]]
|
||||
|
||||
[[9,[[],7,5,[5,10],10],[4,2]],[4,2,3,[[0,9,3],[],2,[4]],2]]
|
||||
[[4,3],[[0,[]],[6,8,[],0,[0]],4]]
|
||||
|
||||
[3,3,9,0,9]
|
||||
[3,3,9,0]
|
||||
|
||||
[[[6,3,4],0,[[],8,1,[7,5],[6,2,1]],8],[8,10,6,[6,6,8,4],[8,[4,3]]],[10,[10,[9,1],[6,3,0,6,4]],3,[],[[0,1,0],3,2,6,1]],[[0,10,[8,5,2]]],[0,[]]]
|
||||
[[[[3,9],[1,6],[]],0,[],[[10,8,2,5,1],[8],[1,1],[5]]]]
|
||||
|
||||
[[[[],8],[],[[10,8]]],[1,5,[[9,7],7,[],[3],10],10],[[8,10,[10,3,5],10,[6,10,6]],[]],[],[3,[[8,6,2,2,8],[7,5,10],8,[0,8]]]]
|
||||
[[6,8]]
|
||||
|
||||
[[3],[],[[[],8,[10,3,1],9,[2,2,4,4]],[0],5,[8,[],5,10,4]],[5,4,[],[6],7]]
|
||||
[[],[[],[[7,3,0,5],7,8,1,[9,7]]],[[[7,10,8]],[[2,1]],[8,[6,1,8,1,6],7,5,[1]]]]
|
||||
|
||||
[[[2,4,8,[]],[]]]
|
||||
[[5,3,5,10],[[]],[7,0,10,10,8],[9,1,8,[10,3],9],[[]]]
|
||||
|
||||
[[[7,[],10,3,7],1,[6,[4,4,4,8],9],2],[],[[9,[],[2]],[5,1,[7,1,0],[]]],[[[9],3,4,1],1],[[5],1,7,2]]
|
||||
[[7,[[8,10,4,7],[6,4,2,1],[9,7,6,8,6]],6],[[[10]],0]]
|
||||
|
||||
[[[[6,3,4,6,1],[5],6,[3,6,7,3],[2]]],[],[5,[0,[4,2,8,1,10],5,4],7],[[3,9,[3,6,0,4],[2,9]],7,1,[[0,9]],[4,[0,3,3,4,0]]]]
|
||||
[[8,5,[9,0],8,3],[2,6],[],[10,[0],8,1,10]]
|
||||
|
||||
[[8,5,0],[9,0,7],[0,0,7]]
|
||||
[[[10,[8,9]],[[],[2,6,3]],[[6,8,5],[3,1,2,2,1],2,[9,7,3,8],[0,10]],3,[9]],[[],[[0,8,9,7,7],[7,10],[8,0],5],5],[[[],5,9]],[[4,[1,8],3],[5,[4,8]]],[[[4],[8,0,5],4,[10,7,10],[]]]]
|
||||
|
||||
[[1,[5,[],[10,3,7],7,9],4],[[[10,5,9,10,1]]],[6]]
|
||||
[[[[],1,10,[10,10]],[8,1,[0],5],[]],[]]
|
||||
|
||||
[[8,6]]
|
||||
[[0],[[[8,3,5],4,[]],9]]
|
||||
|
||||
[[1,0,[[2,5,5]],2]]
|
||||
[[1,1,1],[0,1,7,10]]
|
||||
|
||||
[[],[[[1,8,6,10],10,2],8,[]]]
|
||||
[[7],[[0,8,5],10],[[1],4,2],[7]]
|
||||
|
||||
[[[],5,0,[]],[1,3,9,3],[6,[[6,6]],[[8,1],[3,8],0]],[]]
|
||||
[[6,7,10,[]],[4,[7,10,[3,3,2,4,2],[9,4,3,1],[5,8,0]],[[0,9,10],9,[2],[5,10],5]],[10,3,8,0,[10,6]]]
|
||||
|
||||
[[[]]]
|
||||
[[0,[]],[9],[],[[[1,3,6]],[[1]],6,0]]
|
||||
|
||||
[[[],[]],[1,[7,[7,10,0,10],[7,6],4,[5,8,7,3]],9,[[9,2,3,5]],[[1,5,1],0]],[5,[[]],[[2,9,2,0,10],5,4]]]
|
||||
[[[],[4,[0,0,4,4,2],1],[6,[],[7,3,1,10,6]]],[[9,4,[9,9,8,5],9]],[[0,[3],[4,4],[4],[]],10,[3,[3,3],[6,2,3,2,1],[]],10,7]]
|
||||
|
||||
[[1,1]]
|
||||
[[4,[]],[[[1,0,0,3]],4,[[7,1,0,10,3]],[],[[7,2,2,0]]],[[[8]],2,7],[[[6,8,3,3,6],[1,9,0,8,9],[6,7,0]]],[]]
|
||||
|
||||
[[3,[3,9,[4,7,5,8]],4,[],2],[[[3,0],[5,5,4,7]]],[[[7,4,1,9,5],5],[[0,5,1,5,9],0],[[10,9,10,10]],5,8],[[[1,1],[],[]],[[],[3,5,0,2]]],[[4,[2],5,10],[],1,[],[2,[8,1,0],[]]]]
|
||||
[[3,0,[9],[[],2,[7,5],[9,2,9,3],5],5],[6,8,0,1,8]]
|
||||
|
||||
[[[5,[8,6,2,3]],[[3]],9,2],[],[[],9,[5]]]
|
||||
[[10,[8,9,[],9,0],5,10],[1,9,9,[[4,0,4,10,8],10,[9,5,8,1,4]],[[10,7]]],[[],8,[0],[[2,8],4,[2,0,3]],1],[10,10,8,3,6]]
|
||||
|
||||
[[3,5,1,[2]],[],[],[5]]
|
||||
[[2],[8,9,10,[9,[],6,4,[5,7]]],[3],[1],[]]
|
||||
|
||||
[[5,4,10,[],[[8],[2,5,6,0,1],[5,8,6,8],8]],[5],[3,5,5,2],[[8,10,[4,3],0],[[4,9],8],9,5,[8,[0,6,6,5,8],[]]],[]]
|
||||
[[[[1,9,2],6,6,9],[[],[6,8,1],[9,8,6,9]],2],[[[8,9],4,9,[2,7,7,10],[]],2,5,7],[7,[[7,3,1],[7,1,0],[]]],[8,[],[2,9,10,[]],3],[6,3,[0,1,8],9]]
|
||||
|
||||
[[8,[8,[9,10,5,9]],[[6],9,[5,3,7,8,2]],1,3],[8,5],[[[4,4,7,5],10],0,[6,[0],[],10,4],3]]
|
||||
[[[[4,0,0]],8,10],[[3,1,6],[5,4],0,[[3,2,4,4,1]]]]
|
||||
|
||||
[[],[[[6,6,7],1,[],[1,7]]],[7]]
|
||||
[[[1,[9,4,10],[]],0,[[],[],[],4],5]]
|
||||
|
||||
[[[2,[6,4],[7,9,9,0]],10]]
|
||||
[[4],[],[[[1,1,8],[],[0,7],[6,6,6]],1,7],[[[6,10,2],2,[7,5,4],0,[9]],0,5,5],[4]]
|
||||
|
||||
[[],[7],[0,[7,8,1,[],[3,8,0,3,9]],[6,[10,4,1]],[0,10,2,1]],[]]
|
||||
[[],[4,8,2,[2],4],[],[[[7,7,5],[8,2,10],[4,7],9],6],[[[7],[],8],[],[[2,5],5,[9,4,1,1,2],1],[]]]
|
||||
|
||||
[[[0,3,[9,7,3,4],[],[0,10]],[]],[[8,6,8],1,6],[6,[[],[8]],0,[10]],[[],[[2,10],2,[7,5,9,4],[6]]],[]]
|
||||
[[9,2,6,[[2,8,8],[10,9,0,10,1],2],[[0,1,8]]],[6,[[10,9],6],0,[1,6],[]],[[9,4,[],[6,3,1,3],[5,6,7,7,8]]]]
|
||||
|
||||
[[[0,5],[[6,2,3]]],[[3,[3,5,6]],6,[8,6,10,10]]]
|
||||
[[],[6,2,1],[3,[]]]
|
||||
|
||||
[[5,[3]],[6,[0,[],6],9],[[9,9,6,[4,2,2]]],[[[3],[9,4,3,1]]],[1,[3,[4,8,9,10],6,9],[[],3,[6,9,8],[]]]]
|
||||
[[[0,2,3,[8],[4,5]],0],[[[4,0,7,5,3],4,3,10],[6,[2,4,4,1],[8,9],10],[3],4,[]],[0,6,10,10,[6,1]],[[7,[8,4,1,8]],10,[[6,7,6,9],9,1],[],6],[1,10,10]]
|
||||
|
||||
[[5,8],[6,[[10,6,10,1,0],2,6,[1,10,2],4],3,0],[7],[4,10,[10,[2,2,3,1],6,[8,3,0,2],[9,10,9,5,9]]],[]]
|
||||
[[9,1,[[3,9,2,1,4],3,2],[[],[2,5,7,9,7],9,0,[7,8]]],[]]
|
||||
|
||||
[[4,[[5],[8,1,2],[0]]],[[[2,9,3],7,[1,6,2,2]],2],[],[[3],[[10,10],[7,6,7]]],[[[6,4]],[0]]]
|
||||
[[[9,[],8,[5,4,5],[7,8,9]],0,8,9]]
|
||||
|
||||
[[[0,10,[6,7],[8]],[5,10,[6],4],7,1,2],[],[],[],[10,[],2,8,4]]
|
||||
[[[4]],[],[[],5,7,10],[5,2]]
|
||||
|
||||
[[[[1,9],[3],[5,5,4,4],[2],5]],[2,[[],[0,9,4,4,5],[10,10]],[1,[],[10],4]],[[8,[5,9,8,3,1],3,4,3],[[0,3,0,3,8],[0],[2,3,9,1,2],[0,6,1,9]],[9]],[[[],2,[7],3],[[7],0,[7,9,1,4]],3,[[9,4,6,4,4],[1,8],9,[4]],[[]]],[4]]
|
||||
[[2,[],[10],6,3]]
|
||||
|
||||
[[4]]
|
||||
[[[4,[4,0,5,7],2],[],[9,[1]],2,10],[[0,8,7],8,7,10],[],[3]]
|
||||
|
||||
[[7],[],[5,[[0],[],[4,5,2,3,0],[6,4],[5,9,2,4,1]]],[]]
|
||||
[[],[9,[8,[5,7,7,3],3,[7,0,3,10,0],7]]]
|
||||
|
||||
[[[6],[8,7,5,[4,4,9,0,9],[]],[[0,10,6,6]],1,[]],[[[],[]]],[3,2],[]]
|
||||
[[[]],[[[2,3,0,7],8],1,0],[0,10,0,[3,4,5,[4]],9],[0],[[[3,7],1,2,10],[[4,10],0,5,1],[]]]
|
||||
|
||||
[[[[4,0,5,6],[7,4],9,1]]]
|
||||
[[9,[[6,3,6,0],0,[1,6,0,0],[8,0,0]]],[2,5,[],[[7],8,[8,8],4,1]],[[],[[4,7,8],[],[9,4],4,[]]],[[[10,5,3,9,2],7,3],[7,[9,0,8,10],[9,6]],[5],8,[[],6,[10],[7],2]],[]]
|
||||
|
||||
[[[4,[1,10],[6,3,9],5],9],[]]
|
||||
[[10,[],3,[],[[0,1,10],[3,2,1,3,3],[10,4]]],[]]
|
||||
|
||||
[[[],[[9,9],4,[9,7,2]]],[3,8,0],[10,[3,[10],3]]]
|
||||
[[8,[2,[2,6],1]],[[6,6]],[[[0],4,5],[[3,9],1]],[[[5,7,8],0,[]],[[9,5]],4,[[2,10,0,5,9]],[[],6,9,[],[3,10,10,2]]]]
|
||||
|
||||
[[],[[[5],[4,3,2,10],[],0]],[9,[],[7,10,[6,5,8,5],9,7]],[[7,0,[7,3]]],[]]
|
||||
[[7,[],3,[[],[4,0,0],5,[2,5]],9],[[6,[9],[],[],[4,10]],[[3],[0,4,6],4],[[5,2,2,5],7,[10,8,4,10,3]],[2,[0,7,3,4,7],1,[3,2,8,2]]],[6,5,[[10,5,6,9],6,[8],[1,9,10],7]]]
|
||||
|
||||
[[[[3,2,2],[0,8],[3,2],6,9],[1,[8,10,6],[8,9,5,0,5]]],[1,7,[[4,3],[0,7],[8,6,5],6],[6,6,[2],[8],[7]],[]],[[4,[4,9,3,10,7],[5,0]],3,2,[6,3,0,[]],[[7,7,3],[0,0]]],[[]],[]]
|
||||
[[7],[],[[9,5,[5,7],0],[[2],0,[2,10],0,4]],[7,0,[[8,5,5,7]]],[]]
|
||||
|
||||
[[[9,[5,0,7],10,[6,1,10],[6]],[[1,10,0,0,4],2,[2],6,4]],[[],[[10,5],[7]]]]
|
||||
[[8,[[2,5],7],[[4,4,2],4],6,[]],[[],7,10],[[[4,3,9,6,0],[2]],8]]
|
||||
|
||||
[[8],[[],9,3],[9,9,[[2,5,7,0,3],10,2]]]
|
||||
[[0,[],[[5,2,2,1],[4],[6],4,[5,4,10]],4,3],[4,9],[[[0,8,1,0,0]],[[6,6,2],[4,4,0],[],[6]],6]]
|
||||
|
||||
[[[2,[],7,7,9]],[10,[[8,10,7],[7,9,2,0],7,[5],[3]],3],[3,6,8]]
|
||||
[[1,[[4],[7,5,3,1],[9,8,8,2],10],[],[10],3]]
|
||||
|
||||
[[],[9]]
|
||||
[[2,4,10],[[],8,10,[7,3,5],[8,[10,2,3],4,2]],[1,9,[0,4,[3],[6]],[[8,10,1,4],[],4],[2]],[[]]]
|
||||
|
||||
[[[[],0],3],[[2,3]],[[9,10,[3,7,0],3,[9]],8,7,10],[[[7,3,1]]]]
|
||||
[[4,8],[9,9],[3,1,[[10,0,2,10],6],[],[2,3,[6,0,9],9]],[3,5,3,[[6,9],[2,9,1]],[[6,4,9,3,4],0,[7],[2,7],[9]]]]
|
||||
|
||||
[[5,[8,[5,4,7,8],[1,1,6,5,10]],[7]],[[2]],[[0,[1,8,8,10,3]],[],1],[[2,9,3],10,[0,8,[7,3,0,1]],1]]
|
||||
[[[[4,0,5]],9],[[10,4,7,7],4],[0,[[7,9,6,9],9,10,0],[8,1],0,[8,[4,1],10,[2,9,10,7]]],[[],[6,[1],[5],5,7],[[5,8],9],10,2],[[8,9,1,[4,6]],[],[[],[10,4,2],4,4],[9,[2,4]],3]]
|
||||
|
||||
[7,10,0,6]
|
||||
[7,10,0,6,1]
|
||||
|
||||
[[8,[[0,4,2,1]],[8,3],[[],3]],[4,[[]],[6]]]
|
||||
[[[7,[1,10,1]],[[6,5,9,1],[3,3],[6,2,3,6,2]],[9,[9],8,6,1]],[[[7],[1],[0,7,2,7],7,5],0,1],[3,[[1,7],2,[8,5,6,10,2],7,[9,6,7,9]]],[7,3,1,[4,1],3],[[]]]
|
||||
|
||||
[[[0,1],10,9]]
|
||||
[[2,[[10,0,2],3,[1,1,4],[1]],7,[[],[2,6,10,3,6],[3]]],[[6,[],[0,8,0,1,8]],9,3,10],[10,3,7,9]]
|
||||
|
||||
[[[1,4,[2,2]],[9,[8,6,10],5],[9]],[[[0,4,3]],8,[[9,9,0],[1,2,10]],6,8],[]]
|
||||
[[10,0,[],[],3],[9,[2,10,5,[1,4,3]],4,1]]
|
||||
|
||||
[[3,10,[3,[9,2],[3]],5]]
|
||||
[[4,[8,[0],[5,1,5]],0,[5,[5,8,2,3,9],[]]]]
|
||||
|
||||
[[],[[6,[1,7,9],[],10],7],[],[[3,[],[9,9,6,0,4]],[[7,5,7,2,10],0,[6,10,3],[6,2],[6,6,1,1]],[[1,3,9],[4,7,6,7],6,3,[4]]],[[7,[3]],7]]
|
||||
[[[[10],[9,9,10,1,0],[10,6,9,8,4],4]],[1],[6,[[10,9,6,9,10],4],[[6,7,2,1],[],[4,1,4,1],[]],[5,1],[[2,5],9]],[],[]]
|
||||
|
||||
[[],[[[1,9,9],9,[5,5,5]],[],9,8]]
|
||||
[[[10,5,[2,9,2,1,7]]],[],[[3,8,9,[],[9,9,5]],7,[]],[[7]]]
|
||||
|
||||
[[[[]],3,0,8,[10,[10,6,9,8,3],7,5]],[[[6],5,[9,1,2],[3,4,0,4]],9],[10,[],[2,2,[9,10,5,6]]]]
|
||||
[[2,3]]
|
||||
|
||||
[[1,9,[8,[4],[4,2,0,0],[10,7,1,10],[8,10,10]]],[6,3,8,2,9],[7,[1,1,[4,3],[]],[],9,4]]
|
||||
[[0,10,7,[],5]]
|
||||
|
||||
[[[[4,8,1,4],[]],10,0],[],[],[3]]
|
||||
[[1,[[3,8],[3,4,6,6],[],[6,10]],5,[4,[6,5,10]],9],[7,[],[[2],[],4],3,2],[5,5],[4]]
|
||||
|
||||
[[[[0],3],5,1,6],[[],[[4],9,4,[9]],7,[2,4,[3,0,4,5,5]]],[2],[6,[6,8,[],3],[],6,[[5,8,0,6],10,[1,5,9,4]]],[]]
|
||||
[[4,10,[8,[],[0,5,10,2,6],8],4],[],[[9,10,3],7]]
|
||||
|
||||
[[[6,[5,3],[3],1,[2,4,9,4]]],[],[[[1,2,2],5,1]],[8,[8,[7,2,7],[9],7,8],2,[0,1],6]]
|
||||
[[[[6,9,0,0]],3,[5],9,[[8,1,5,4,10],6,[]]],[3],[[[1,5,1,2],8,1],[8],[3,[4,4,8,3,3],[0],[7,7,0,3],9]]]
|
||||
|
||||
[[7],[1,1,0],[[2],[[1,0,6,8,6],[3,4,8,10,9],2,[6]],10],[[[8,8,9,0],[],3],[1],[9,1,[6,0]]]]
|
||||
[[],[2,5,2,4,5],[1,6],[[2,[],[6,4,2],9],4,[5,[5,4,1,3,8],0],[2,[9],1,[],6]],[]]
|
||||
|
||||
[[3,6,8,[]],[]]
|
||||
[[[[8,7],4,[]],3,[3,[0],[5,4]],7],[[],[4,6,[6,4,9,4,2],0],10,[8,8,2,0]],[[[3,0,6,10],[8,9]],[[3,7],[7,9,6,5,9]],[]]]
|
||||
|
||||
[[[8,2,[9,5,1,2,2],[0,10,0,5,7],[1,8]],8],[4,[],[7,[],1,[],0],[[5],3],7],[1,[[],[4,2,8,1]],8,4]]
|
||||
[[7],[[5,6]],[6,[2,8,[],2,[6,3]]],[[[1,1],2],6,[[6,10,7],1,[8]],[[],10,2]],[]]
|
||||
|
||||
[[],[8]]
|
||||
[[],[[[9],6],0,8,[3,[],9,[],1],[1,6]]]
|
||||
|
||||
[[[8,[6,0,9,10]],[[6,1,8,3,1],[9,4,10,1,5],[2,7,5,3,4],[2]],10,7,[5,[8,3]]],[4,10,[[4],[]]]]
|
||||
[[[[5,8,0,9,7],6,5],[],1,[]],[1,[],[[0,7],[1,10],[3],[0,0,10,7],0],[[9,8,1],[]],[[6,1,10,6],[4,9,4],[8],0]],[2,9,[4],1]]
|
||||
|
||||
[[9,[8,2,0,[7,10,9,7]]],[8,[[0,10,9],0],[8,[7,0,0,2]]],[],[[]]]
|
||||
[[2,[[3,2,7]],[0,[6,6,0,4,5]],[10,[3,6]],[]],[0,10,[],[7],[[7],5]]]
|
||||
|
||||
[[9,[[3],6,[10,4],6,[9]]]]
|
||||
[[[[5,1,2,10,3],[7,7,1,8]],3],[9,[],[[3,7,6]],6],[[[4,8,10,3],0]],[[8],[[1,4]],[5,[6,7,7,3]],7,9]]
|
||||
|
||||
[[[10,[8,1,2],2,1],2,[3,[6,2],[10],[7,10],4]]]
|
||||
[[[9,8],7,[[0,6,9],[8,1],[8]],[7,[],0]],[9,0,[[1,2],4,8,[],[]],[1],9],[[]],[]]
|
||||
|
||||
[[2,3,[9],[[8,1,1,10,4],[2,3,9,2,7],1,4]],[],[[2,6,6,[4,5,2,8,3],9],0,[[1,9],6,[6,6,0,5,10]],9],[[5,[],7,7,4],[5],6]]
|
||||
[[[4,0,[3,6,3,5],0],4,[],[7,[4,1,3,3],5,[4,4,4,2],[10,8]],1],[]]
|
||||
|
||||
[[],[0,[[],[0],1,5]],[5,[5,1,[5,6,8,4,0],7,[4]],[0,[]],0],[8,1,2,10],[2,[9,[7,8],3],[9,10,3,[10,3,8]]]]
|
||||
[[[1,0,8,5],4],[],[]]
|
||||
|
||||
[[1,[10,[7],[],[7,7,7,1],6]],[8,[4,[0,7]]],[[]],[[],[[6,4,2,8,6],7,[9,0,3,6]],9]]
|
||||
[[],[10,2,[],3,0]]
|
||||
|
||||
[[6,[[2,10,10]]],[[[],[]]],[1,9,2,3,[[5,3,9],6]],[10,[[5],9,[8,0,4],[8,6,4,6]]]]
|
||||
[[],[[6,[2,2],9,0],7,[[7,4,2,1,4],6,[0,10,5,10]],1,[[7,9,5,7,1],5,[],4,10]]]
|
||||
|
||||
[[9,6],[[9,[7,0,1,7,7],[]],[1,[7],[9,3,9,3]],0,[[]]],[9,6],[]]
|
||||
[[[[],0,[3,2,1,2,1]],10,[5]]]
|
||||
|
||||
[[],[7],[[6,4,0,7,[6,4,0]],2,1,[[7,3],8,[2,2,10],7],5],[]]
|
||||
[[],[7,8,[[10,5],[10,0,10,4,5],4,[10,3,6,4],[]],8],[],[3],[2,8]]
|
||||
|
||||
[[[[5],8,[],9],[[1,5,8,9],[8,2,5,2,10]],[],8,4],[1,4,9],[],[[4,7,3,0]],[[8],[3,[8,10,8,9],4,1],[[9]],[5,1,[],[7,5,2]],[5]]]
|
||||
[[6,7,[3],[]],[[[1],[10,1],5,4],3,[[0,8,10]],10]]
|
||||
|
||||
[[2,3,[0,[0,1,10,1,8]],[[6,0,4,10],[3],6,3],10]]
|
||||
[[7,5,[[5,5],9,[4,3],[4,8,7,8],5],8,[3,3,7,[]]],[1,[[6,9],[4,0,4,2,3],1,[1]],3,[],[6,5]],[[8]],[[[0,8],[0,8,4,5],2]],[4,[[],[7,9],[6,0,7]],10]]
|
||||
|
||||
[[[6],[[9,9,2,6],2,7,1,1],[],[7,[9,4],[7,5,10,3,1],[2,1,5,7],8]],[[3],[[2,8,1,10,2],1,[4,6],[5]],[2,[0,5,1,5,2]],[]]]
|
||||
[[3,7,[]],[8,8],[[6,3,5,[6]],10,[8],10],[[3,[3,10],10,[],[3,8]],0,[0,2]],[1,6]]
|
||||
|
||||
[[7,1,[10,[],[8]],[5,2,[1],[0,0,1,4]],3],[5,[0,0],10,[7,5,[],3]],[[[0,5,5],4],10,[9,[4],[10,3,7,1]],[[8,10,1,10,1],2,4,[9,3],[2,9,0]]],[[[0],[3,8,9,5],0,[4,2]],8,9,[[4,0],4,[1]]],[[4]]]
|
||||
[[[[0],2]],[[9,[5],[6,4,0],[8,7,5,5,5],3],[[8,3],[],10,10]],[3,6,8],[9,[3,[2]],2,[10,[3,5,2,10],8,3],1]]
|
||||
|
||||
[[9,5,2],[],[5,[[4,6],5,3,3,7]],[[7,5,[],[5,10]],[],[],[[8,9,1],1]]]
|
||||
[[0],[[[]],7,1,2,4],[[[1,2,10,1,8],[7,10,9]],[],[[]],0],[10,9]]
|
||||
|
||||
[[1,[[10],2,5,8]],[],[],[5,[],6],[]]
|
||||
[[[[3,3,8],4,4],9,[7]],[]]
|
||||
|
||||
[[[4,[0,0],6,4],3,[[3,8]]],[[[1,3,7,0]]],[[[]],1,[[10,1,3,8],[5,8],3,[6,5,4,4]]],[[0,1,3,[8,6],[1,0,10]],4,[],[[6,8,6,4],[4,0,8],[],0,7]],[[[],7,[],8],9,[],3]]
|
||||
[[[6,[4],10,[1,2,6,10,6]]],[[[6,5],6,[2],1]],[[[6]],[1],[[9,5,5,2],8,5,8],[1,[]],[]],[7,[[2,8,0,4,5],4,7,[7,3,4,5,7],[]],4],[[7,2,5,5,5],[[6,1,5,5,10],[4,10,6,3,8],[2,8,6,0,1]],[[1,1],4]]]
|
||||
|
||||
[[0]]
|
||||
[[[[],[7,3],[6,7,9]]]]
|
||||
|
||||
[[],[5,4,7],[[[6,1,10],2,[5,7,9,5],[]],[0,[1,10],[8,4,5,0,7],[9],[10,0,5,5,9]],[[4],[],[],[6]],[7],1]]
|
||||
[[[[],0],[2],2],[],[[8,[0,5],7,[7,6,0,6],[3,0,3]],1,10,9],[9,8,[6],7],[]]
|
||||
|
||||
[[9,[0,[4,8],[7,4,2,6,6]]],[[9,[6,5,3,6],10,5,4]]]
|
||||
[[[2,[4],[7],5],[[3,2,5,10,9],3,[10,5,8,4],3]],[]]
|
||||
|
||||
[[],[],[9,[[8,7,6,6],7,0],[4],5],[[[5,7,4,0],1]]]
|
||||
[[[1,6],5,[],[1,[10]]],[0,[[9,8,10,8,10],0,7],5,[[5,3,8,10],[7,9,2,0,0],8],[0,[6,0],4,[0,7]]],[[7,[5],3,6]]]
|
||||
|
||||
[[1],[9,[[2,9]],[[2,1,1]],9,[]],[9,[8,[8,2,6,3,1]],1,0]]
|
||||
[[[5,1,0,0],[5,7,5,0,[]],3,8]]
|
||||
|
||||
[[[],8,8,6],[[5,[],[9,8,2,9]]],[],[3],[3]]
|
||||
[[4,1,[2,5]]]
|
||||
|
||||
[[[[7,8,8,3],7,10],[[7,0,4,4],0],10]]
|
||||
[[8,5],[4],[10],[5,7,[0,[8,7,2,3]],[]]]
|
||||
|
||||
[[10]]
|
||||
[[[[2],8]],[],[],[1,3,[[3,4],[],[1,1,2,9]],[8,0,[9,0],3,[3,5,6]],1],[[8]]]
|
||||
|
||||
[[[[5],[4,6],[0,8,10,0,7]]],[[3,[6],10,2],[],5],[],[]]
|
||||
[[[[2,1,2,9,9]],[[9],[1,4,4],8,[4,5,4,6],7],[[7,9,5],[5,2,0,4]],5],[[9],[[4,2],[1,7,5,9]],4,10,[2]],[2,6,2,7,[[9],[0],1,10,[3]]],[2,1,2,10]]
|
||||
|
||||
[[[[5,0]],3,[8,2,10],[[7,6,2,9],9,5,[7,2,8,10,9]],0],[[[3,7],7,[]],6],[5],[1,3,3,[[3,9,8],[1,3,7,6],1,[8,0,8],8],[[2,3],[6,1],[8],8,4]]]
|
||||
[[[8,[1,8,3,9,6]],2,[10],[9,[0,0],[],0]],[[[4,0,8],0,6,8,[1,4]]],[7,2,[0,6,[4,8,0]],1,5],[2],[[[2,3]],9]]
|
||||
|
||||
[[3,[5],8]]
|
||||
[[5],[[7,[7,2,8],[5,2,6,7],9,7],0,[],5],[[],2,3,[[8,9,2,0,8]]]]
|
||||
|
||||
[[[[10,10],[6,10,10]],[],[3]],[10,1,[[],6,[3,9,0,1],[4,9],5]],[]]
|
||||
[[[0,[8]],[5,0,[3,8,6,5,1]],10,[9,[3,9,9,7,3],2,[1,0]]],[3,3,[[4,10]],3,[[0,7,4],5,[],[6,5,5,3,2]]],[[6,3,[],4,[10,1,0,0,1]],8],[[],[],8],[6,[7,[]],[]]]
|
||||
|
||||
[[[4,0,[6,10,8,1,2]],[],7,1,[6,[0],8,[6,8,8,10,5]]],[[2],1],[[],4],[0,[9,[10,9],1,9]]]
|
||||
[[5,10],[[],7],[[6,[1,9,10,0,9],3,[]],5,[[7,7,3,2,7],[]],[],7]]
|
||||
|
||||
[[2,1,9,3]]
|
||||
[[[]],[8,[[2],3,[10],[]]]]
|
||||
|
||||
[[[9,7],[3,[]],4],[10,[9],[],[[5,7,0],[4,9,5,5,5],[5,2,0,5],3],[[],5,[1,6,0,2],[],[]]],[[],[0],[[6]],10,4]]
|
||||
[[9,10,[6,7,8],5]]
|
||||
|
||||
[[[[9,5,4,8],[],[4,3,8,4,4],2],[1,3,5],[[],1],[8],[]],[5],[0,8,4,[9,4,3,5,[3,8,10,4,6]]],[[3,1],10,7,6],[2]]
|
||||
[[4,2,[[1,8,2,7],1,4,10,5]],[5,[[5],2,[0,6,6,5],1,[7]],0,7,[[7,3,3]]],[[5,8,[0]],5,[],5],[[]],[[],[3,4,[5,8,0],[3,8,10]],5,1,3]]
|
||||
|
||||
[[8,4,8,9],[[[7,6,6,3],6,2,5,[5,7,6]],[],0],[[[5,7,10],0],[[5,4],3],7,2],[]]
|
||||
[[5],[[4,[10,6],0,6,[5,8,5,1,1]],9,5,7,[7,4,6,10,7]],[1,[4]],[3,[1],5,[3,[2,8,10],4,8]],[9,[[5,0],1,[4,0,6],[7,0]]]]
|
||||
|
||||
[[[[10,8,8,5,2],3,[0,1,8,7,9],6],7,1],[],[[1,8,1],[4,[8],[6,9],5]],[[4],[[1,9],[9,2],[4],[10,10],[10,1]],9,2],[]]
|
||||
[[[5,[]]],[[[3],[10,1,0,1,7],[9,10,7]],10,5,6],[],[[8,[2,5,7,7],8]],[7,[[4],[8,8,6],9],[[10,6,8]],1,[]]]
|
||||
|
||||
[[],[[[1,6,1,5],[2,5,5,3],[],0,5],[],[5],8]]
|
||||
[[[[8,3,3,3,1],[3,8,0,8,10],[6,10],[]],[8,[9],[4,3,9,8],[]],3,[],[[8,0]]]]
|
||||
|
||||
[[[[0,7,2,9]],[5,[5,4,7],9,[9,8,2,4]],10,[[7,3,2],4,[8,3,0,10,1],[1,5]],7],[1,10,1],[]]
|
||||
[[[3],[10,[],[1,0,5]],[[9,8,8,8]]],[[7,9,2,1,[]],[4],[3,[10,0,3,0],7,[6]],10,[4,6,[2]]],[[[0],[],[10],1],6]]
|
||||
|
||||
[[8,[[]],0,0,9],[0,0,3,[],[[9,7,2],[3,7,7,2],[7,6,4],6,5]]]
|
||||
[[],[6,8,[4,7],[2,10,[4],[1],[6,1,5]],7],[8]]
|
||||
|
||||
[[3,[[1,0,8,5],5,[],[4],[]],5,[3,6,10,[],7],9],[4,[6,[4,4,5]],[]]]
|
||||
[[0],[0,[5,4,5,8,6],3],[10,6,[]],[5,5,10,6,10],[10,[0]]]
|
||||
|
||||
[[]]
|
||||
[[],[2],[8,7]]
|
||||
|
||||
[[],[[],7,[5],2,3]]
|
||||
[[[5,[9,5,10],6,[10,6],4]],[[[4,9,10,9,1],[8,2,4],5,[10,10,5],7],[2,9,2,6]]]
|
||||
|
||||
[[],[]]
|
||||
[[3,2,[[3,3],10,7],3],[],[[],[]],[[[8,10,10,4,8],9,[4,8,3,0,4]],[8]]]
|
||||
|
||||
[[[0,[9,3,10,2,4],4]]]
|
||||
[[],[2],[[9,6,5,[3,5,8,4],[9,9,3,6]],[8,[4,1,3],[]],0,0],[[7,2,[3,9,6,0],3,[1,3,10,0,3]],10,[[7,0,4,10],9,3],[[7],[7,6,6,4,10],[10,5,2,5],[4,1,10,8]]],[9,[[3]],[1,[9,6,10],[6,2]],[0,7]]]
|
||||
|
||||
[[3,[[],9,6,5,6],[]],[[[6],7],6],[5],[4,[4,0,[5]]]]
|
||||
[[],[3,[],[8,[10,4,7]],[[10,3,4,1,10],4,5,8]],[[[6,4,2,8],[],5]],[5,0]]
|
||||
|
||||
[[4,[[],[]],[]],[]]
|
||||
[[5,6,0],[[2,0],[[8]],8,9],[1,6,2]]
|
||||
|
||||
[[[10,[],3,[8,1],[2,0,1,3,7]],3,[[1,6,4,2],[8,9,3,7],[1],[4,6,1,6]],7,[[0,1,7],[7]]],[[4,[4,0,6,1],7],2,5,10,[[7,10,4,3],1,5,[],5]],[[[2,6],[6],[6],[9,6,1],9],[[3,6,2,4],9,4,4],9,5]]
|
||||
[[6,[],8]]
|
||||
|
||||
[[],[[[],[9,10,3,0],4,10]]]
|
||||
[[3,8,1],[],[9,6,2,1],[10,2,3,[[],1],[[1]]]]
|
||||
|
||||
[[10,[],[[],1,8,3,[9]],[[],2]]]
|
||||
[[[[9,10]],1],[[7,6,6,[2,2,0],[3,1,10,0]],6,[]],[9,[[3,9,8,5],[4],1],[[8,10,8],4,[2,1,1]],6]]
|
||||
|
||||
[[],[[]],[[7],7,6,0,[]],[[[1,0,6],3,10,6],[[3,2],[5,6,7],3,[],[2,4,0,2]]],[]]
|
||||
[[[[4,4,3,7],[2,5,3],8,10],0],[],[6],[[[1,9],[],[4,6,5,4],[10,2,10,9,2],3],6,[3,7,[3,8],[7]]]]
|
||||
|
||||
[[9,5],[0],[[4,[],[]],[8,[]]],[8,[9]]]
|
||||
[[[[3,8,6,0],[9,9,9,3,0],1,9,6],9,[0,1,8],[6,[7,8]]],[5,9,4],[[[5,8,2]],[1,[],1,7,6],9,[7,7,2]],[],[]]
|
||||
|
||||
[[[[5,4,8,7,4],8,2,7,10],4,[0,6,[6,9,2,6]]],[],[[1,[5]]],[5,6,9,1]]
|
||||
[[],[6,4],[[[3,0,2]],[8,1,[6,7,5,5],2],[7,5,6],[],10],[4,[[],6,[]]]]
|
||||
|
||||
[[[[],3],9],[[0,4,[2,2,2]]],[],[[2,9,6,[9,9,2]],2],[[6,4,6,5],6,6]]
|
||||
[[],[[[],[],4,2],0,7],[[[9,7,6,10],9]]]
|
||||
|
||||
[[7,[[8,2,6],[7,6,10,8],[4,6],[0,7,3,1],7],7,[[7],[],[9,0,5,2],[8]],[4,[9,8,10]]],[[10],[1,8,0,[]],[7,[8],8,7],[[3,2,1,3],9],[[10,0,8,10,7],0,[2,0,4,1]]],[[3,[6,0,2],[1,10],7],5,7,1,[]]]
|
||||
[[5,0],[8,[[10],[]],[9,10],[7,[9,4,0,5,0],6,4,[3]],[6]],[],[[0,[],[3,1,1],[],[9,9]]],[]]
|
||||
|
||||
[[0],[0,[7,7,[3,5,2],3,[0,1,9,8]],[[10],[10,4,5,5,6]],[[4,9,4,8],2,[3],[7,5,2,7]]]]
|
||||
[[[[9,4,1],[4,10]]],[2,[4],[],[[],[3,2,5],7,4],[6]]]
|
||||
|
||||
[[7,[[],8,[8,2,8,2],[3,1,3,10]]],[5,[],2,5,7],[2,[[]]],[],[[[],[2,6,8]],9,[2,2,3],[3]]]
|
||||
[[4],[[]]]
|
||||
|
||||
[[[0,4],[6,1],8],[],[2],[]]
|
||||
[[],[[[2,4],[8],0]]]
|
||||
|
||||
[[3,[7,[6],2,4]],[7,[[]]],[6,7,8,6,0],[],[]]
|
||||
[[],[9,0,1,[2,6,[3],[8,4,8,0,8],[2,1,4,7,1]]]]
|
||||
|
||||
[[[0],0,0,[]],[],[[3,8,7],4,[[8,6,5],[1,9,8]],[],2]]
|
||||
[[3],[5,1,[1,[4,7,3,5,7],[7,1,5,3],[9,4,3]]],[1,[3,[4,7,10,8],[6,6,4,3,7],[4,1,7],8]],[7,[6,[0,2,8,10,10]]]]
|
||||
|
||||
[[9,[],[]],[[9,[4,2,10,5,0],0],1,10,[1,[2,0,5,2],[6,1],[2],4],5],[4,[10,[1,6,6,9,10],[5],[5,2]],2,[[4,4,6]]],[1,[],10,7],[10,[4,4,[0,6,10,6,0],4],1,3,[3,9,[5]]]]
|
||||
[[[[2],[],7,[6],[9,8,5,5]],[[3,6],5,9,[7,3,6],[]],10],[10,[[8],[4,7,10,4,3]]]]
|
||||
|
||||
[[4],[1]]
|
||||
[[[],7,[[],[9,4]]],[[6,[7,1,0],[7,0,3],5],7,4,7,9],[[3,[4,10]],8,9,1,[1,[0,9,0,9]]]]
|
||||
|
||||
[[4,[[8]]]]
|
||||
[[2],[[[]]]]
|
||||
|
||||
[[8,8,3],[]]
|
||||
[[4,10,[10,0],9,4],[[],[[9,5,8,8,7],3,[3,8,2]],[[10],[7,8,2],[3],[2,8,7]]],[],[1,4,[9,8,5],6],[[8,1,[9,7,6],[8,10,10,0,9]],[],8]]
|
||||
|
||||
[[2,[[1,10,8,10],3,10,0,[0,10,5]],3],[3,[[8],[3,0,3,7]]]]
|
||||
[[],[[[2,10,3,7,9],6,[3,10,4],[7]]],[],[10,[2,[]],1,8,1]]
|
||||
|
||||
[[3],[5,3,2,[[7],1,[5,9,0,9,4],[4,8,1,1],7]],[[1],2,[1,[10,6,7,10],9],5,7],[],[]]
|
||||
[[[0,[],10],[8,[],2]],[[[0,4,8,2],10,1,8],[5,2,3,[8,4,8,5,4],[0,5]],[7,8,3],[6,1,[10,8]]],[6,[],2],[]]
|
||||
|
||||
[[],[7,[[1],7,0],[6,3,[9,9]],4]]
|
||||
[[],[4,[],[[6,6,3],9]]]
|
||||
|
||||
[[9,[5,[9,8,2],9],0,9],[[[9,4,2]],2,2],[5,[],0,[[0,8,10,6],2],[[2,7],[9,5],9]]]
|
||||
[[7,[[6,4,2,4,3],[9,3,7]],2,1,9]]
|
||||
|
||||
[[3]]
|
||||
[[6,[[6,0,8],[3,3,5,8],[]],[[4],[10,1,7,9],7,[]],8],[2,2],[[[3,0,7],[2,1,10,1,9],4,9]],[4],[9]]
|
||||
|
||||
[[[],7,5,6,[]],[9,[[3,2],0,[1,3,9,8,5]],3,10,3],[7,8,[7],[8],2],[[],[[7],4]]]
|
||||
[[[[6,2],3,7,[6,5,3,0],5],2,0,[[5]]],[6,4,3],[],[]]
|
||||
|
||||
[[7,[[1,3,0,1,3],[3,1,1,2,2]],5,10,[0,10,2,5]]]
|
||||
[[[],1,1,[]],[],[[],[1],[2],0,[[0,7,7,2,2],[2,6,8,1]]]]
|
||||
|
||||
[[5,10,7,9]]
|
||||
[[3],[9,8,[[9,8,0],9,[7],5,[]],7],[[[2,6,10,7],1]],[3,[5,[7,1,10,0,10],6,9],10,4],[[4,8,[7,4,8,4,4],[],[3]],7,6]]
|
||||
|
||||
[[[[1],[4,6]],[1,3,5]],[],[8,0],[[5,1,6,2],[],[[],1,[4,9]],[3,[10,9,5,5],[0,0,0]],4],[3]]
|
||||
[[9],[[[4,3,6,0,3],3,[],[0,10,3,4],5],5,3,[[7]]],[]]
|
||||
|
||||
[[5,3,5]]
|
||||
[[],[4,[[1],[7],4,[],2],[],[[2,4,4,3,3],0,3,8]],[5,[],[[],5,1,4,2]]]
|
||||
|
||||
[[2,[[6],1],1],[[[7,5,5],7,9,9],6,[1,4,10]]]
|
||||
[[[[0,8,8,1],[8,8,10],[5],[8,8,10,2],2],9,5,[7,1],3],[4,[4,[9,1,1,3,10]]],[1,[],[2,[9,0,4,3,10]],[5]],[[],10,7]]
|
||||
|
||||
[[[0,[1,4,6,4,10],10],[1],6,2],[10,0,7,[4,[9],4,8,5],[10,[9,6,7,5,2],[1,6,6,2]]],[[2,[1,4],[6,5,3],4],[[6,7,7,8],[9,2,8,4]],9,7]]
|
||||
[[[5,[2,0,0,8],[8,5]],[[3],9,[9,0,0,0],[1],9],[2],[[],2,1,9]],[],[[9,5,7],6,[6],[10,[2,9,4],[],[]],9],[2]]
|
||||
|
||||
[[5,[0,[10,4,0,1,5],[8,4],9,[6]],[[4,5,10,5,7],[],[2,5,9,7],[5,3,2,6],[6,3,1]],6,[]],[0],[2]]
|
||||
[[[],0,6],[[7,[5],[7],[7]],[[0,5]],[[8,0,10],[0,2,4,8,2]],10,[[]]],[[],[5],[[],10,1,4]],[6,[[2,5],[1],8,5],[[],[0,4,0,10],[10,6]],[2,8,[],10],10],[8,[10,[7,3,2],[10,3]],1,1]]
|
||||
|
||||
[[[],[],[[]],0],[0,10,[9],[[0,5,1]]]]
|
||||
[]
|
||||
|
||||
[[[10,[4,3,9],[7]],0,[9,3,0,7],9],[[]],[[[9,2,7],[6,10,8,9,10],10,8,[9,1,2,9,1]],[[10,4],[8,9,4]],5,[[9,1,6,2,10],[0,6,0,2],[4,7,8,2],[5,10,5,10,8]],[[0,3,1,9,1],[2,0,4],[7,9],[0,5,1,0,6]]],[5,5],[9]]
|
||||
[[[[6],2,[3,0],[0,5,5],7],[4,[0,9,9,0]],[10,[6,7]],9,[1,[1,0,7,2],[4,2,6,7,3],[5,9,3]]],[],[[[10],[10],[]],[[9,1,9]],[1,10,[]],5],[2,5,[7,[3,8],[]]],[]]
|
||||
|
||||
[[[[4,4,2,3],[8,4,0,4,2],[],[9,1,7]],[],[[6,7,8,4,6],4,8]],[8,[],7],[]]
|
||||
[[5,5,[[3,10,1],4,8,[4,1,10,0,1]],8,[[9,2,1,6],8,[9,7,8,3,8],[3,6,10,1]]],[[[5,0,10,6],[0],[7,2,0],[1,1,1,2,3]],[0,[0,7,10,4],8,[10,9],[]]],[10],[[[10,7],[0,1,4],[0,6,5,3]]],[]]
|
||||
|
||||
[[[[10,6,4,9,9],[3,3,9,5,4],[9,6,1,7,6]],8,[]],[5,[[],[0,6],[9,8,6],7],10,[8]],[3,7,[6]]]
|
||||
[[8],[],[[0,[2,4],[7]],[[8,3],9,[6]],[4,1],[6,2,10,1],[7,7,[2,1,2,4]]]]
|
||||
|
||||
[[[[9,5],9,[8,1],[0,3,6,9],[6]],[[0,10,2,2],6]],[[[9,5,5]]],[6],[3,[],9,[[5,4,8,6,6],[10,6,6],[],9],1],[3,0,[[],9,[4],2]]]
|
||||
[[5,[],[[]]],[[10,[],[8,8,6,9],[1,4],[5,2,7,9,6]],2,9],[],[[],2,5,[5,6,1,8],0]]
|
||||
32
day13/part1.py
Normal file
32
day13/part1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
|
||||
lines = (json.loads(x.strip()) for x in open("input.txt") if x != "\n")
|
||||
|
||||
def is_first_list_smaller(m1, m2):
|
||||
for i1, i2 in zip(m1, m2):
|
||||
if isinstance(i1, list) and not isinstance(i2, list):
|
||||
i2 = [i2]
|
||||
elif not isinstance(i1, list) and isinstance(i2, list):
|
||||
i1 = [i1]
|
||||
|
||||
if isinstance(i1, list) and isinstance(i2, list):
|
||||
cmp = is_first_list_smaller(i1, i2)
|
||||
if cmp is not None:
|
||||
return cmp
|
||||
else:
|
||||
continue
|
||||
|
||||
if i1 < i2:
|
||||
return True
|
||||
if i2 < i1:
|
||||
return False
|
||||
return True if len(m1) < len(m2) else None if len(m1) == len(m2) else False
|
||||
|
||||
s = []
|
||||
for idx, line in enumerate(lines, 1):
|
||||
nxt = next(lines)
|
||||
if is_first_list_smaller(line, nxt):
|
||||
s.append(idx)
|
||||
|
||||
print(sum(s))
|
||||
37
day13/part2.py
Normal file
37
day13/part2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
|
||||
lines = (json.loads(x.strip()) for x in open("input.txt") if x != "\n")
|
||||
|
||||
|
||||
def is_first_list_smaller(m1, m2):
|
||||
for i1, i2 in zip(m1, m2):
|
||||
if isinstance(i1, list) and not isinstance(i2, list):
|
||||
i2 = [i2]
|
||||
elif not isinstance(i1, list) and isinstance(i2, list):
|
||||
i1 = [i1]
|
||||
|
||||
if isinstance(i1, list) and isinstance(i2, list):
|
||||
cmp = is_first_list_smaller(i1, i2)
|
||||
if cmp is not None:
|
||||
return cmp
|
||||
else:
|
||||
continue
|
||||
|
||||
if i1 < i2:
|
||||
return True
|
||||
if i2 < i1:
|
||||
return False
|
||||
return True if len(m1) < len(m2) else None if len(m1) == len(m2) else False
|
||||
|
||||
|
||||
s2 = 1
|
||||
s6 = 2
|
||||
for line in lines:
|
||||
if is_first_list_smaller(line, [[2]]):
|
||||
s2 += 1
|
||||
s6 += 1
|
||||
elif is_first_list_smaller(line, [[6]]):
|
||||
s6 += 1
|
||||
|
||||
print(s2 * s6)
|
||||
123
day14/input.txt
Normal file
123
day14/input.txt
Normal file
@@ -0,0 +1,123 @@
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
511,86 -> 515,86
|
||||
485,22 -> 489,22
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
509,150 -> 513,150
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
494,24 -> 498,24
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
497,154 -> 501,154
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
523,80 -> 527,80
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
505,17 -> 510,17
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
498,17 -> 503,17
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
509,31 -> 509,32 -> 513,32 -> 513,31
|
||||
504,90 -> 504,91 -> 513,91 -> 513,90
|
||||
493,48 -> 493,49 -> 512,49 -> 512,48
|
||||
479,26 -> 483,26
|
||||
488,24 -> 492,24
|
||||
512,152 -> 516,152
|
||||
491,26 -> 495,26
|
||||
493,48 -> 493,49 -> 512,49 -> 512,48
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
517,80 -> 521,80
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
514,83 -> 518,83
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
529,86 -> 533,86
|
||||
526,83 -> 530,83
|
||||
497,13 -> 502,13
|
||||
516,108 -> 516,109 -> 520,109 -> 520,108
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
503,154 -> 507,154
|
||||
494,15 -> 499,15
|
||||
520,77 -> 524,77
|
||||
506,152 -> 510,152
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
493,48 -> 493,49 -> 512,49 -> 512,48
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
516,108 -> 516,109 -> 520,109 -> 520,108
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
488,20 -> 492,20
|
||||
500,152 -> 504,152
|
||||
509,31 -> 509,32 -> 513,32 -> 513,31
|
||||
509,154 -> 513,154
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
523,86 -> 527,86
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
491,22 -> 495,22
|
||||
497,26 -> 501,26
|
||||
506,148 -> 510,148
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
494,157 -> 494,159 -> 491,159 -> 491,167 -> 503,167 -> 503,159 -> 499,159 -> 499,157
|
||||
516,108 -> 516,109 -> 520,109 -> 520,108
|
||||
501,15 -> 506,15
|
||||
516,125 -> 516,129 -> 515,129 -> 515,136 -> 526,136 -> 526,129 -> 519,129 -> 519,125
|
||||
491,17 -> 496,17
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
512,139 -> 512,142 -> 509,142 -> 509,145 -> 521,145 -> 521,142 -> 517,142 -> 517,139
|
||||
504,90 -> 504,91 -> 513,91 -> 513,90
|
||||
503,45 -> 503,41 -> 503,45 -> 505,45 -> 505,43 -> 505,45 -> 507,45 -> 507,37 -> 507,45 -> 509,45 -> 509,35 -> 509,45 -> 511,45 -> 511,37 -> 511,45
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
482,24 -> 486,24
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
509,31 -> 509,32 -> 513,32 -> 513,31
|
||||
516,65 -> 516,69 -> 508,69 -> 508,74 -> 521,74 -> 521,69 -> 520,69 -> 520,65
|
||||
512,122 -> 512,118 -> 512,122 -> 514,122 -> 514,120 -> 514,122 -> 516,122 -> 516,121 -> 516,122
|
||||
515,154 -> 519,154
|
||||
517,86 -> 521,86
|
||||
485,26 -> 489,26
|
||||
504,90 -> 504,91 -> 513,91 -> 513,90
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
510,104 -> 510,96 -> 510,104 -> 512,104 -> 512,101 -> 512,104 -> 514,104 -> 514,100 -> 514,104 -> 516,104 -> 516,103 -> 516,104
|
||||
503,150 -> 507,150
|
||||
520,83 -> 524,83
|
||||
508,62 -> 508,56 -> 508,62 -> 510,62 -> 510,52 -> 510,62 -> 512,62 -> 512,60 -> 512,62 -> 514,62 -> 514,58 -> 514,62 -> 516,62 -> 516,55 -> 516,62
|
||||
62
day14/part1.py
Normal file
62
day14/part1.py
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
import math
|
||||
from functools import reduce
|
||||
from itertools import count
|
||||
|
||||
import numpy as np
|
||||
|
||||
lines = list(np.array([[int(z) for z in y.split(',')] for y in x.strip().split(" -> ")]) for x in open("input.txt"))
|
||||
|
||||
|
||||
all = reduce(lambda x, y: np.concatenate((x, y)), lines, np.array([[500, 0]]))
|
||||
span = np.zeros((2, 2), dtype=int)
|
||||
span[0] = np.min(all, axis=0)
|
||||
span[1] = np.max(all, axis=0) + 1
|
||||
print(span)
|
||||
grid = np.full(tuple(span[1]-span[0]), False)
|
||||
|
||||
for line in lines:
|
||||
line = line-span[0]
|
||||
#print("line", line)
|
||||
for a, b in zip(line[:-1], line[1:]):
|
||||
a, b = np.min((a, b), axis=0), np.max((a, b), axis=0)
|
||||
#print("pair", a, b)
|
||||
grid[a[0]:b[0]+1, a[1]:b[1]+1] = True
|
||||
#print('\n+'.join(''.join('#' if p else '.' for p in l) for l in grid.T))
|
||||
|
||||
def drop():
|
||||
x, y = 500-span[0, 0], 0
|
||||
if grid[y, x]:
|
||||
return False
|
||||
while True:
|
||||
#print("Test", x-span[0, 0], y)
|
||||
if y+1 == grid.shape[1]:
|
||||
return None
|
||||
elif not grid[x, y+1]:
|
||||
y += 1
|
||||
elif x == 0:
|
||||
return None
|
||||
elif not grid[x-1, y+1]:
|
||||
x, y = x-1, y+1
|
||||
elif x+1 == grid.shape[0]:
|
||||
return None
|
||||
elif not grid[x+1, y+1]:
|
||||
x, y = x+1, y+1
|
||||
else:
|
||||
return x, y
|
||||
|
||||
|
||||
for cnt in count():
|
||||
pos = drop()
|
||||
#print(pos)
|
||||
|
||||
if pos is None:
|
||||
print("Res", cnt)
|
||||
break
|
||||
if not pos:
|
||||
print("Start is occupied!")
|
||||
break
|
||||
grid[pos] = True
|
||||
print('\n'.join(''.join('#' if p else '.' for p in l) for l in grid.T))
|
||||
|
||||
|
||||
37
day14/part2.py
Normal file
37
day14/part2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
from itertools import count
|
||||
|
||||
lines = ([[int(z) for z in y.split(',')] for y in x.strip().split(" -> ")] for x in open("input.txt"))
|
||||
blocked = set()
|
||||
bottom = 0
|
||||
|
||||
for line in lines:
|
||||
for a, b in zip(line[:-1], line[1:]):
|
||||
for x in range(min(a[0], b[0]), max(a[0], b[0])+1):
|
||||
for y in range(min(a[1], b[1]), max(a[1], b[1])+1):
|
||||
blocked.add((x, y))
|
||||
bottom = max(bottom, y)
|
||||
|
||||
|
||||
def drop():
|
||||
x, y = 500, 0
|
||||
if (x, y) in blocked:
|
||||
return False
|
||||
while y-1 != bottom:
|
||||
for nxt in ((x, y+1), (x-1, y+1), (x+1, y+1)):
|
||||
if nxt not in blocked:
|
||||
x, y = nxt
|
||||
break
|
||||
else:
|
||||
return x, y
|
||||
return x, y
|
||||
|
||||
|
||||
for cnt in count():
|
||||
pos = drop()
|
||||
if not pos:
|
||||
print("Start is occupied!", cnt)
|
||||
break
|
||||
blocked.add(pos)
|
||||
|
||||
|
||||
22
day15/input.txt
Normal file
22
day15/input.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
Sensor at x=1384790, y=3850432: closest beacon is at x=2674241, y=4192888
|
||||
Sensor at x=2825953, y=288046: closest beacon is at x=2154954, y=-342775
|
||||
Sensor at x=3553843, y=2822363: closest beacon is at x=3444765, y=2347460
|
||||
Sensor at x=2495377, y=3130491: closest beacon is at x=2761496, y=2831113
|
||||
Sensor at x=1329263, y=1778185: closest beacon is at x=2729595, y=2000000
|
||||
Sensor at x=2882039, y=2206085: closest beacon is at x=2729595, y=2000000
|
||||
Sensor at x=3903141, y=2510440: closest beacon is at x=4006219, y=3011198
|
||||
Sensor at x=3403454, y=3996578: closest beacon is at x=3754119, y=4475047
|
||||
Sensor at x=3630476, y=1048796: closest beacon is at x=3444765, y=2347460
|
||||
Sensor at x=16252, y=2089672: closest beacon is at x=-276514, y=2995794
|
||||
Sensor at x=428672, y=1150723: closest beacon is at x=-281319, y=668868
|
||||
Sensor at x=2939101, y=3624676: closest beacon is at x=2674241, y=4192888
|
||||
Sensor at x=3166958, y=2890076: closest beacon is at x=2761496, y=2831113
|
||||
Sensor at x=3758241, y=3546895: closest beacon is at x=4006219, y=3011198
|
||||
Sensor at x=218942, y=3011070: closest beacon is at x=-276514, y=2995794
|
||||
Sensor at x=52656, y=3484635: closest beacon is at x=-276514, y=2995794
|
||||
Sensor at x=2057106, y=405314: closest beacon is at x=2154954, y=-342775
|
||||
Sensor at x=1966905, y=2495701: closest beacon is at x=2761496, y=2831113
|
||||
Sensor at x=511976, y=2696731: closest beacon is at x=-276514, y=2995794
|
||||
Sensor at x=3094465, y=2478570: closest beacon is at x=3444765, y=2347460
|
||||
Sensor at x=806671, y=228252: closest beacon is at x=-281319, y=668868
|
||||
Sensor at x=3011731, y=1976307: closest beacon is at x=2729595, y=2000000
|
||||
29
day15/part1.py
Normal file
29
day15/part1.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
target = 2000000
|
||||
intervals = []
|
||||
known_targets = set()
|
||||
|
||||
for line in lines:
|
||||
x, y, a, b = map(int, re.search(r"(-?\d+).+?(-?\d+).+?(-?\d+).+?(-?\d+)", line).groups())
|
||||
dist = abs(x-a) + abs(y-b)
|
||||
width = dist-abs(y-target)
|
||||
if width >= 0:
|
||||
intervals.append((x-width, x+width))
|
||||
if b == target:
|
||||
known_targets.add(a)
|
||||
if y == target:
|
||||
known_targets.add(x)
|
||||
|
||||
|
||||
intervals.sort(key=lambda x: x[0])
|
||||
merged = [intervals[0]]
|
||||
for i in intervals[1:]:
|
||||
if merged[-1][1] >= i[0]:
|
||||
merged[-1] = (merged[-1][0], max(merged[-1][1], i[1]))
|
||||
else:
|
||||
merged.append(i)
|
||||
|
||||
print(sum(b-a+1 for a, b in merged)-len(known_targets))
|
||||
25
day15/part2.py
Normal file
25
day15/part2.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
# all lines of possible positions
|
||||
# mx+b; tl/br have m=1; tr/bl have m=-1
|
||||
tl, tr, bl, br = set(), set(), set(), set()
|
||||
stations = []
|
||||
|
||||
for line in lines:
|
||||
x, y, bx, by = map(int, re.search(r"(-?\d+).+?(-?\d+).+?(-?\d+).+?(-?\d+)", line).groups())
|
||||
dist = abs(x-bx) + abs(y-by) + 1
|
||||
tl.add(y-dist+x)
|
||||
br.add(y+dist+x)
|
||||
bl.add(y+dist-x)
|
||||
tr.add(y-dist-x)
|
||||
stations.append((x, y, dist))
|
||||
|
||||
for bu, bd in ((a, b) for a in tl & br for b in tr & bl):
|
||||
# -x+bu=x+bd <=> x=(bd-bu)/2
|
||||
x = (bu-bd)//2
|
||||
y = x+bd
|
||||
|
||||
if all(abs(x-sx)+abs(y-sy) >= dist for sx, sy, dist in stations):
|
||||
print(x*4000000+y)
|
||||
60
day16/input.txt
Normal file
60
day16/input.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
Valve HM has flow rate=0; tunnels lead to valves LS, YS
|
||||
Valve IY has flow rate=15; tunnels lead to valves YI, MU, KN, QS, QM
|
||||
Valve VI has flow rate=22; tunnels lead to valves LE, SE, RB, JR
|
||||
Valve SE has flow rate=0; tunnels lead to valves VI, AZ
|
||||
Valve QU has flow rate=0; tunnels lead to valves YC, QK
|
||||
Valve RB has flow rate=0; tunnels lead to valves AN, VI
|
||||
Valve PU has flow rate=0; tunnels lead to valves JR, IM
|
||||
Valve OA has flow rate=0; tunnels lead to valves KZ, FR
|
||||
Valve AQ has flow rate=23; tunnels lead to valves FA, QM, GE
|
||||
Valve QS has flow rate=0; tunnels lead to valves IM, IY
|
||||
Valve HC has flow rate=24; tunnel leads to valve XH
|
||||
Valve QI has flow rate=0; tunnels lead to valves KQ, LS
|
||||
Valve FA has flow rate=0; tunnels lead to valves HA, AQ
|
||||
Valve BA has flow rate=0; tunnels lead to valves KZ, ME
|
||||
Valve DH has flow rate=0; tunnels lead to valves LT, HA
|
||||
Valve TE has flow rate=0; tunnels lead to valves AA, ZJ
|
||||
Valve AA has flow rate=0; tunnels lead to valves YS, XT, TE, GY, FS
|
||||
Valve YC has flow rate=9; tunnels lead to valves DV, XH, DJ, QU
|
||||
Valve KN has flow rate=0; tunnels lead to valves IY, AZ
|
||||
Valve GS has flow rate=0; tunnels lead to valves FS, KZ
|
||||
Valve DJ has flow rate=0; tunnels lead to valves YC, UV
|
||||
Valve GY has flow rate=0; tunnels lead to valves QK, AA
|
||||
Valve ZJ has flow rate=6; tunnels lead to valves RC, HS, UV, ME, TE
|
||||
Valve RC has flow rate=0; tunnels lead to valves BY, ZJ
|
||||
Valve QK has flow rate=10; tunnels lead to valves QU, XX, HS, RM, GY
|
||||
Valve AN has flow rate=0; tunnels lead to valves HA, RB
|
||||
Valve XT has flow rate=0; tunnels lead to valves AA, KQ
|
||||
Valve LT has flow rate=0; tunnels lead to valves IM, DH
|
||||
Valve YI has flow rate=0; tunnels lead to valves LE, IY
|
||||
Valve BK has flow rate=0; tunnels lead to valves LS, RM
|
||||
Valve LE has flow rate=0; tunnels lead to valves VI, YI
|
||||
Valve IM has flow rate=19; tunnels lead to valves PU, EC, QS, LT
|
||||
Valve SK has flow rate=0; tunnels lead to valves RF, AZ
|
||||
Valve RM has flow rate=0; tunnels lead to valves QK, BK
|
||||
Valve YM has flow rate=0; tunnels lead to valves LS, KZ
|
||||
Valve DV has flow rate=0; tunnels lead to valves YC, AI
|
||||
Valve QM has flow rate=0; tunnels lead to valves IY, AQ
|
||||
Valve KZ has flow rate=5; tunnels lead to valves BA, GS, YM, OA, XX
|
||||
Valve FS has flow rate=0; tunnels lead to valves GS, AA
|
||||
Valve UV has flow rate=0; tunnels lead to valves DJ, ZJ
|
||||
Valve AZ has flow rate=20; tunnels lead to valves SE, KN, SK, MS
|
||||
Valve BY has flow rate=0; tunnels lead to valves RC, LS
|
||||
Valve OY has flow rate=0; tunnels lead to valves KQ, EI
|
||||
Valve XX has flow rate=0; tunnels lead to valves KZ, QK
|
||||
Valve ME has flow rate=0; tunnels lead to valves BA, ZJ
|
||||
Valve YS has flow rate=0; tunnels lead to valves AA, HM
|
||||
Valve MS has flow rate=0; tunnels lead to valves AZ, HA
|
||||
Valve HS has flow rate=0; tunnels lead to valves QK, ZJ
|
||||
Valve LS has flow rate=3; tunnels lead to valves BK, HM, QI, BY, YM
|
||||
Valve KQ has flow rate=17; tunnels lead to valves OY, XT, QI
|
||||
Valve MU has flow rate=0; tunnels lead to valves IY, HA
|
||||
Valve EC has flow rate=0; tunnels lead to valves IM, GE
|
||||
Valve XH has flow rate=0; tunnels lead to valves HC, YC
|
||||
Valve JR has flow rate=0; tunnels lead to valves PU, VI
|
||||
Valve EI has flow rate=0; tunnels lead to valves OY, RF
|
||||
Valve AI has flow rate=25; tunnel leads to valve DV
|
||||
Valve GE has flow rate=0; tunnels lead to valves AQ, EC
|
||||
Valve RF has flow rate=18; tunnels lead to valves EI, FR, SK
|
||||
Valve FR has flow rate=0; tunnels lead to valves OA, RF
|
||||
Valve HA has flow rate=12; tunnels lead to valves AN, FA, MU, MS, DH
|
||||
39
day16/part1.py
Normal file
39
day16/part1.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
lines = (re.search(r"([A-Z]{2}).*?(\d+).*?([A-Z]{2}(?:, [A-Z]{2})*)", line).groups() for line in lines)
|
||||
nodes = {name: (int(p), [(1, neighbor) for neighbor in neighbors.split(", ")]) for name, p, neighbors in lines}
|
||||
|
||||
for name in [*nodes.keys()]:
|
||||
(p, edges) = nodes[name]
|
||||
if len(edges) != 2 or p != 0:
|
||||
continue
|
||||
dist = sum(e[0] for e in edges)
|
||||
(_, edge1), (_, edge2) = edges
|
||||
idx = next(i for i, (_, edge_node) in enumerate(nodes[edge1][1]) if edge_node == name)
|
||||
nodes[edge1][1][idx] = (dist, edge2)
|
||||
idx = next(i for i, (_, edge_node) in enumerate(nodes[edge2][1]) if edge_node == name)
|
||||
nodes[edge2][1][idx] = (dist, edge1)
|
||||
del nodes[name]
|
||||
|
||||
def solve(pos, opened, minute, released, per_minute, path):
|
||||
if minute < 30 and (minute < 10 or released > 100) and (minute < 20 or released > 800):
|
||||
pressure, neighbors = nodes[pos]
|
||||
# open the value
|
||||
if pos not in opened and pressure > 0:
|
||||
yield from solve(pos, {pos, *opened}, minute+1, released+per_minute, per_minute+pressure, [*path, ("drain", pos, minute, released)])
|
||||
# go to neighbor
|
||||
if len(opened) < len(nodes)-1:
|
||||
for dist, name in neighbors:
|
||||
yield from solve(name, opened, minute+dist, released+per_minute*dist, per_minute, [*path, ("move", pos, "to", name, minute, released)])
|
||||
# finish
|
||||
yield released + (30-minute+1)*per_minute, [*path, ("finish", pos, minute, released, per_minute)]
|
||||
|
||||
mx = 0
|
||||
for val, path in solve("AA", set(), 1, 0, 0, []):
|
||||
if val > mx:
|
||||
print(val, path)
|
||||
mx = val
|
||||
|
||||
# 2253 [('move', 'AA', 'to', 'KQ', 1, 0), ('drain', 'KQ', 3, 0), ('move', 'KQ', 'to', 'RF', 4, 0), ('drain', 'RF', 7, 51), ('move', 'RF', 'to', 'AZ', 8, 68), ('drain', 'AZ', 10, 138), ('move', 'AZ', 'to', 'VI', 11, 173), ('drain', 'VI', 13, 283), ('move', 'VI', 'to', 'IM', 14, 338), ('drain', 'IM', 17, 569), ('move', 'IM', 'to', 'IY', 18, 646), ('drain', 'IY', 20, 838), ('move', 'IY', 'to', 'AQ', 21, 934), ('drain', 'AQ', 23, 1156), ('move', 'AQ', 'to', 'HA', 24, 1267), ('drain', 'HA', 26, 1535), ('move', 'HA', 'to', 'IY', 27, 1669), ('finish', 'IY', 29, 1961, 146)]
|
||||
37
day16/part2.py
Normal file
37
day16/part2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
import itertools
|
||||
import random
|
||||
import re
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
lines = (re.search(r"([A-Z]{2}).*?(\d+).*?([A-Z]{2}(?:, [A-Z]{2})*)", line).groups() for line in lines)
|
||||
nodes = {name: (int(p), neighbors.split(", ")) for name, p, neighbors in lines}
|
||||
|
||||
|
||||
def solve(positions, lasts, opened, minute, released, per_minute, path):
|
||||
if minute < 26 and (minute < 10 or released > 220) and (minute < 15 or released > 720) and (minute < 20 or released > 1480):
|
||||
def possibilites(pos, last):
|
||||
pressure, neighbors = nodes[pos]
|
||||
# open the value
|
||||
if pos not in opened and pressure > 0:
|
||||
yield (pos, {pos, }, pressure, "drain "+pos+" ("+str(pressure)+")")
|
||||
# go to neighbor
|
||||
if len(opened) < len(nodes) - 1:
|
||||
for name in random.sample(neighbors, len(neighbors)):
|
||||
if name != last:
|
||||
yield (name, set(), 0, "goto "+name)
|
||||
lists = [list(possibilites(p, l)) for p, l in zip(positions, lasts)]
|
||||
for nexts, opening, releasing, actions in (list(zip(*x)) for x in itertools.product(*lists)):
|
||||
if len(set().union(*opening)) == sum(len(o) for o in opening):
|
||||
yield from solve(nexts, positions, opened.union(*opening), minute+1, released+per_minute, per_minute+sum(releasing), [*path, (actions, minute, released, per_minute)])
|
||||
# finish
|
||||
if minute > 20:
|
||||
yield released + (26-minute+1)*per_minute, [*path, ("finish", positions, minute, released, per_minute)]
|
||||
|
||||
mx = 0
|
||||
for val, path in solve(["AA", "AA"], [None, None], set(), 1, 0, 0, []):
|
||||
if val > mx:
|
||||
print(val, path)
|
||||
mx = val
|
||||
|
||||
# 2838 [(('goto GY', 'goto XT'), 1, 0, 0), (('goto QK', 'goto KQ'), 2, 0, 0), (('drain QK (10)', 'drain KQ (17)'), 3, 0, 0), (('goto QU', 'goto OY'), 4, 0, 27), (('goto YC', 'goto EI'), 5, 27, 27), (('drain YC (9)', 'goto RF'), 6, 54, 27), (('goto DV', 'drain RF (18)'), 7, 81, 36), (('goto AI', 'goto SK'), 8, 117, 54), (('drain AI (25)', 'goto AZ'), 9, 171, 54), (('goto DV', 'drain AZ (20)'), 10, 225, 79), (('goto YC', 'goto SE'), 11, 304, 99), (('goto XH', 'goto VI'), 12, 403, 99), (('goto HC', 'drain VI (22)'), 13, 502, 99), (('drain HC (24)', 'goto JR'), 14, 601, 121), (('goto XH', 'goto PU'), 15, 722, 145), (('goto YC', 'goto IM'), 16, 867, 145), (('goto DJ', 'drain IM (19)'), 17, 1012, 145), (('goto UV', 'goto QS'), 18, 1157, 164), (('goto ZJ', 'goto IY'), 19, 1321, 164), (('drain ZJ (6)', 'drain IY (15)'), 20, 1485, 164), (('goto ME', 'goto QM'), 21, 1649, 185), (('goto BA', 'goto AQ'), 22, 1834, 185), (('goto KZ', 'drain AQ (23)'), 23, 2019, 185), (('drain KZ (5)', 'goto FA'), 24, 2204, 208), ('finish', ('KZ', 'FA'), 25, 2412, 213)]
|
||||
2071
day18/input.txt
Normal file
2071
day18/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
16
day18/part1.py
Normal file
16
day18/part1.py
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
cnt = 0
|
||||
matches = 0
|
||||
cubes = set()
|
||||
|
||||
for line in lines:
|
||||
x, y, z = map(int, line.split(","))
|
||||
matches += sum((x+nx*s, y+ny*s, z+nz*s) in cubes for s in (1, -1) for nx, ny, nz in ((1, 0, 0), (0, 1, 0), (0, 0, 1)))
|
||||
cnt += 1
|
||||
cubes.add((x, y, z))
|
||||
|
||||
print(matches, cnt, len(cubes))
|
||||
print(len(cubes)*6-matches*2)
|
||||
23
day18/part2.py
Normal file
23
day18/part2.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
queue = [(0, 0, 0)]
|
||||
cnt = 0
|
||||
visited = set()
|
||||
cubes = set()
|
||||
|
||||
for line in lines:
|
||||
x, y, z = map(int, line.split(","))
|
||||
cubes.add((x, y, z))
|
||||
|
||||
while queue:
|
||||
x, y, z = queue.pop(0)
|
||||
for xn, yn, zn in ((1, 0, 0), (0, 1, 0), (0, 0, 1), (-1, 0, 0), (0, -1, 0), (0, 0, -1)):
|
||||
neighbor = (x+xn, y+yn, z+zn)
|
||||
if neighbor in cubes:
|
||||
cnt += 1
|
||||
elif neighbor not in visited and -2 <= neighbor[0] < 22 and -2 <= neighbor[1] < 22 and -2 <= neighbor[2] < 22:
|
||||
queue.append(neighbor)
|
||||
visited.add(neighbor)
|
||||
|
||||
print(cnt)
|
||||
141
day18/task.html
Normal file
141
day18/task.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Day 18 - Advent of Code 2022</title>
|
||||
<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
|
||||
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/style.css?30"/>
|
||||
<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
|
||||
<link rel="shortcut icon" href="/favicon.png"/>
|
||||
<script>window.addEventListener('click', function(e,s,r){if(e.target.nodeName==='CODE'&&e.detail===3){s=window.getSelection();s.removeAllRanges();r=document.createRange();r.selectNodeContents(e.target);s.addRange(r);}});</script>
|
||||
</head><!--
|
||||
|
||||
|
||||
|
||||
|
||||
Oh, hello! Funny seeing you here.
|
||||
|
||||
I appreciate your enthusiasm, but you aren't going to find much down here.
|
||||
There certainly aren't clues to any of the puzzles. The best surprises don't
|
||||
even appear in the source until you unlock them for real.
|
||||
|
||||
Please be careful with automated requests; I'm not a massive company, and I can
|
||||
only take so much traffic. Please be considerate so that everyone gets to play.
|
||||
|
||||
If you're curious about how Advent of Code works, it's running on some custom
|
||||
Perl code. Other than a few integrations (auth, analytics, social media), I
|
||||
built the whole thing myself, including the design, animations, prose, and all
|
||||
of the puzzles.
|
||||
|
||||
The puzzles are most of the work; preparing a new calendar and a new set of
|
||||
puzzles each year takes all of my free time for 4-5 months. A lot of effort
|
||||
went into building this thing - I hope you're enjoying playing it as much as I
|
||||
enjoyed making it for you!
|
||||
|
||||
If you'd like to hang out, I'm @ericwastl on Twitter.
|
||||
|
||||
- Eric Wastl
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-->
|
||||
<body>
|
||||
<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2022/about">[About]</a></li><li><a href="/2022/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2022/settings">[Settings]</a></li><li><a href="/2022/auth/logout">[Log Out]</a></li></ul></nav><div class="user">TheCaesar2011 <span class="star-count">32*</span></div></div><div><h1 class="title-event"> <span class="title-event-wrap">y(</span><a href="/2022">2022</a><span class="title-event-wrap">)</span></h1><nav><ul><li><a href="/2022">[Calendar]</a></li><li><a href="/2022/support">[AoC++]</a></li><li><a href="/2022/sponsors">[Sponsors]</a></li><li><a href="/2022/leaderboard">[Leaderboard]</a></li><li><a href="/2022/stats">[Stats]</a></li></ul></nav></div></header>
|
||||
|
||||
<div id="sidebar">
|
||||
<div id="sponsor"><div class="quiet">Our <a href="/2022/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://www.twilio.com/quest" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">TwilioQuest</a> - Discover your power to change the world with code with TwilioQuest, an educational RPG. Learn foundational programming skills, JavaScript and Python while you explore The Cloud alongside our community of developers.</div></div>
|
||||
</div><!--/sidebar-->
|
||||
|
||||
<main>
|
||||
<article class="day-desc"><h2>--- Day 18: Boiling Boulders ---</h2><p>You and the elephants finally reach fresh air. You've emerged near the base of a large volcano that seems to be actively erupting! Fortunately, the lava seems to be flowing away from you and toward the ocean.</p>
|
||||
<p>Bits of lava are still being ejected toward you, so you're sheltering in the cavern exit a little longer. Outside the cave, you can see the lava landing in a pond and hear it loudly hissing as it solidifies.</p>
|
||||
<p>Depending on the specific compounds in the lava and speed at which it cools, it might be forming <a href="https://en.wikipedia.org/wiki/Obsidian" target="_blank">obsidian</a>! The cooling rate should be based on the surface area of the lava droplets, so you take a quick scan of a droplet as it flies past you (your puzzle input).</p>
|
||||
<p>Because of how quickly the lava is moving, the scan isn't very good; its resolution is quite low and, as a result, it approximates the shape of the lava droplet with <em>1x1x1 <span title="Unfortunately, you forgot your flint and steel in another dimension.">cubes</span> on a 3D grid</em>, each given as its <code>x,y,z</code> position.</p>
|
||||
<p>To approximate the surface area, count the number of sides of each cube that are not immediately connected to another cube. So, if your scan were only two adjacent cubes like <code>1,1,1</code> and <code>2,1,1</code>, each cube would have a single side covered and five sides exposed, a total surface area of <code><em>10</em></code> sides.</p>
|
||||
<p>Here's a larger example:</p>
|
||||
<pre><code>2,2,2
|
||||
1,2,2
|
||||
3,2,2
|
||||
2,1,2
|
||||
2,3,2
|
||||
2,2,1
|
||||
2,2,3
|
||||
2,2,4
|
||||
2,2,6
|
||||
1,2,5
|
||||
3,2,5
|
||||
2,1,5
|
||||
2,3,5
|
||||
</code></pre>
|
||||
<p>In the above example, after counting up all the sides that aren't connected to another cube, the total surface area is <code><em>64</em></code>.</p>
|
||||
<p><em>What is the surface area of your scanned lava droplet?</em></p>
|
||||
</article>
|
||||
<p>To begin, <a href="18/input" target="_blank">get your puzzle input</a>.</p>
|
||||
<form method="post" action="18/answer"><input type="hidden" name="level" value="1"/><p>Answer: <input type="text" name="answer" autocomplete="off"/> <input type="submit" value="[Submit]"/></p></form>
|
||||
<p>You can also <span class="share">[Share<span class="share-content">on
|
||||
<a href="https://twitter.com/intent/tweet?text=%22Boiling+Boulders%22+%2D+Day+18+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F18&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
|
||||
<a href="javascript:void(0);" onclick="var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=%22Boiling+Boulders%22+%2D+Day+18+%2D+Advent+of+Code+2022+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F18'}else{return false;}" target="_blank">Mastodon</a
|
||||
></span>]</span> this puzzle.</p>
|
||||
</main>
|
||||
|
||||
<!-- ga -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-69522494-1', 'auto');
|
||||
ga('set', 'anonymizeIp', true);
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
<!-- /ga -->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user