Compare commits
13 Commits
57a73a13f7
...
e8b37bdddb
| Author | SHA1 | Date | |
|---|---|---|---|
| e8b37bdddb | |||
| 7074c08023 | |||
| dd78a9b7c6 | |||
| 9648e656f0 | |||
| f3e239292a | |||
| dbbf97c64d | |||
| a5d1167aec | |||
| d317513134 | |||
| 318727ec3e | |||
| 2373b52af3 | |||
|
|
e65156225e | ||
|
|
09dbf8c0c0 | ||
|
|
0a7f2f288f |
107
answer_cache.json
Normal file
107
answer_cache.json
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"1": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 522
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 73364
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 7410
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": "cnjxoritzhvbosyewrmqhgkul"
|
||||
}
|
||||
},
|
||||
"3": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 121259
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 239
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 95199
|
||||
},
|
||||
"2": {
|
||||
"wrong": [
|
||||
10923,
|
||||
15226
|
||||
],
|
||||
"correct": 7887
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 9348
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 4996
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"1": {
|
||||
"wrong": [
|
||||
4787
|
||||
],
|
||||
"correct": 4771
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 39149
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": "JMQZELVYXTIGPHFNSOADKWBRUC"
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 1133
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 40746
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 37453
|
||||
}
|
||||
},
|
||||
"9": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": 412959
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": 3333662986
|
||||
}
|
||||
},
|
||||
"11": {
|
||||
"1": {
|
||||
"wrong": [],
|
||||
"correct": "243,34"
|
||||
},
|
||||
"2": {
|
||||
"wrong": [],
|
||||
"correct": "90,214,15"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
aoc2018.nim
19
aoc2018.nim
@ -1,19 +0,0 @@
|
||||
import std/intsets
|
||||
import std/sequtils
|
||||
import tools/aoc
|
||||
|
||||
let test: AOCDay = initAOCDay(1)
|
||||
printSolution(1, 1, test.getInputInt().foldl(a + b))
|
||||
|
||||
var seen: IntSet = initIntSet()
|
||||
var freq: int = 0
|
||||
var found: bool = false
|
||||
while not found:
|
||||
for x in test.getInputInt():
|
||||
freq += x
|
||||
if freq notin seen:
|
||||
seen.incl(freq)
|
||||
else:
|
||||
printSolution(1, 2, freq)
|
||||
found = true
|
||||
break
|
||||
@ -1,17 +0,0 @@
|
||||
import std/os
|
||||
|
||||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
author = "Stefan Harmuth"
|
||||
description = "aoc2018"
|
||||
license = "GPL-3.0-or-later"
|
||||
srcDir = "."
|
||||
bin = @["aoc2018"]
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
||||
rmDir(joinPath(getHomeDir(), "/.nimble/pkgs/tools-#head"))
|
||||
requires "nim >= 1.6.0"
|
||||
requires "ssh://git@leeloo.drock.de/nim-tools.git#head"
|
||||
@ -1 +0,0 @@
|
||||
switch("define", "release")
|
||||
35
day01.py
Normal file
35
day01.py
Normal file
@ -0,0 +1,35 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(522, "input1")
|
||||
],
|
||||
[
|
||||
(73364, "input1")
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
freq = 0
|
||||
for f in self.getInputListAsType(int):
|
||||
freq += f
|
||||
|
||||
return freq
|
||||
|
||||
def part2(self) -> Any:
|
||||
freq = 0
|
||||
freq_set = set()
|
||||
while True:
|
||||
for f in self.getInputListAsType(int):
|
||||
freq_set.add(freq)
|
||||
freq += f
|
||||
if freq in freq_set:
|
||||
return freq
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 1)
|
||||
day.run(verbose=True)
|
||||
52
day02.py
Normal file
52
day02.py
Normal file
@ -0,0 +1,52 @@
|
||||
from collections import defaultdict
|
||||
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(12, "test_input2_1"),
|
||||
(7410, "input2")
|
||||
],
|
||||
[
|
||||
('fgij', "test_input2_2"),
|
||||
('cnjxoritzhvbosyewrmqhgkul', "input2")
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
twos, threes = 0, 0
|
||||
for label in self.getInput():
|
||||
count = defaultdict(int)
|
||||
for x in label:
|
||||
count[x] += 1
|
||||
|
||||
if 2 in count.values():
|
||||
twos += 1
|
||||
if 3 in count.values():
|
||||
threes += 1
|
||||
|
||||
return twos * threes
|
||||
|
||||
def part2(self) -> Any:
|
||||
for x, l1 in enumerate(self.getInput()):
|
||||
for l2 in self.getInput()[x + 1:]:
|
||||
miss = 0
|
||||
miss_id = -1
|
||||
for i, c in enumerate(l1):
|
||||
if not c == l2[i]:
|
||||
miss += 1
|
||||
miss_id = i
|
||||
|
||||
if miss > 1:
|
||||
break
|
||||
|
||||
if miss == 1:
|
||||
return l1[:miss_id] + l1[miss_id + 1:]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 2)
|
||||
day.run(verbose=True)
|
||||
58
day03.py
Normal file
58
day03.py
Normal file
@ -0,0 +1,58 @@
|
||||
from tools.aoc import AOCDay
|
||||
from tools.coordinate import Square, Coordinate
|
||||
from tools.grid import Grid
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(121259, "input3")
|
||||
],
|
||||
[
|
||||
(3, "test_input3"),
|
||||
(239, "input3")
|
||||
]
|
||||
]
|
||||
|
||||
def getClaims(self) -> list:
|
||||
claims = []
|
||||
for line in self.getInput():
|
||||
_, _, coord, size = line.split()
|
||||
x, y = map(int, coord[:-1].split(","))
|
||||
dx, dy = map(int, size.split("x"))
|
||||
claims.append(Square(Coordinate(x, y), Coordinate(x + dx - 1, y + dy - 1)))
|
||||
|
||||
return claims
|
||||
|
||||
def part1(self) -> Any:
|
||||
fabric = Grid()
|
||||
for claim in self.getClaims():
|
||||
fabric.add_shape(claim)
|
||||
|
||||
count = 0
|
||||
for x in fabric.values():
|
||||
if x > 1:
|
||||
count += 1
|
||||
|
||||
return count
|
||||
|
||||
def part2(self) -> Any:
|
||||
claims = self.getClaims()
|
||||
|
||||
for i, claim in enumerate(claims):
|
||||
inter = False
|
||||
for claim2 in claims:
|
||||
if claim2 == claim:
|
||||
continue
|
||||
if claim.intersection(claim2):
|
||||
inter = True
|
||||
break
|
||||
|
||||
if not inter:
|
||||
return i + 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 3)
|
||||
day.run(verbose=True)
|
||||
79
day04.py
Normal file
79
day04.py
Normal file
@ -0,0 +1,79 @@
|
||||
import datetime
|
||||
from collections import defaultdict
|
||||
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(240, "test_input4_1"),
|
||||
(95199, "input4")
|
||||
],
|
||||
[
|
||||
(4455, "test_input4_1"),
|
||||
(7887, "input4")
|
||||
]
|
||||
]
|
||||
|
||||
def get_guards(self) -> dict:
|
||||
active_guard = 0
|
||||
sleep_start = 0
|
||||
guards = {}
|
||||
|
||||
for event in sorted(self.getInput()):
|
||||
time, msg = event.split("] ")
|
||||
timestamp = datetime.datetime.strptime(time, "[%Y-%m-%d %H:%M")
|
||||
if msg.startswith("Guard"):
|
||||
active_guard = int(msg.split()[1][1:])
|
||||
if active_guard not in guards:
|
||||
guards[active_guard] = {
|
||||
'total': 0,
|
||||
'minutes': defaultdict(int)
|
||||
}
|
||||
elif msg.startswith("falls asleep"):
|
||||
if timestamp.hour == 0:
|
||||
sleep_start = timestamp.minute
|
||||
elif msg.startswith("wakes up"):
|
||||
guards[active_guard]['total'] += timestamp.minute - sleep_start
|
||||
for m in range(sleep_start, timestamp.minute):
|
||||
guards[active_guard]['minutes'][m] += 1
|
||||
|
||||
return guards
|
||||
|
||||
def part1(self) -> Any:
|
||||
guards = self.get_guards()
|
||||
max_guard = 0
|
||||
max_minutes = 0
|
||||
most_minute = 0
|
||||
for guard, data in guards.items():
|
||||
if data['total'] < max_minutes:
|
||||
continue
|
||||
max_guard = guard
|
||||
max_minutes = data['total']
|
||||
most_minute = sorted(data['minutes'], key=lambda k: data['minutes'][k], reverse=True)[0]
|
||||
|
||||
return max_guard * most_minute
|
||||
|
||||
def part2(self) -> Any:
|
||||
guards = self.get_guards()
|
||||
max_guard = 0
|
||||
max_minute = 0
|
||||
max_time = 0
|
||||
for guard, data in guards.items():
|
||||
if not data['minutes']:
|
||||
continue
|
||||
most_minute = sorted(data['minutes'], key=lambda k: data['minutes'][k], reverse=True)[0]
|
||||
if data['minutes'][most_minute] < max_time:
|
||||
continue
|
||||
max_guard = guard
|
||||
max_time = data['minutes'][most_minute]
|
||||
max_minute = most_minute
|
||||
|
||||
return max_guard * max_minute
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 4)
|
||||
day.run(verbose=True)
|
||||
68
day05.py
Normal file
68
day05.py
Normal file
@ -0,0 +1,68 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
def react(polymer: str) -> str:
|
||||
reacted = True
|
||||
while reacted:
|
||||
reacted = False
|
||||
new_poly = ""
|
||||
i = 0
|
||||
while i < len(polymer) - 1:
|
||||
if abs(ord(polymer[i]) - ord(polymer[i + 1])) != 32:
|
||||
new_poly += polymer[i]
|
||||
else:
|
||||
i += 1
|
||||
reacted = True
|
||||
|
||||
i += 1
|
||||
if i < len(polymer):
|
||||
new_poly += polymer[-1]
|
||||
|
||||
polymer = new_poly
|
||||
|
||||
return polymer
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(10, "test_input5_1"),
|
||||
(9348, "input5")
|
||||
],
|
||||
[
|
||||
(4, "test_input5_1"),
|
||||
(4996, "input5")
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
polymer = self.getInput()
|
||||
return len(react(polymer))
|
||||
|
||||
def part2(self) -> Any:
|
||||
polymer = self.getInput()
|
||||
tested = set()
|
||||
min_length = len(polymer)
|
||||
for c in polymer:
|
||||
if c in tested:
|
||||
continue
|
||||
|
||||
tested.add(c.upper())
|
||||
tested.add(c.lower())
|
||||
|
||||
test_polymer = ""
|
||||
for x in polymer:
|
||||
if x != c.upper() and x != c.lower():
|
||||
test_polymer += x
|
||||
|
||||
this_length = len(react(test_polymer))
|
||||
if this_length < min_length:
|
||||
min_length = this_length
|
||||
|
||||
return min_length
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 5)
|
||||
day.run(verbose=True)
|
||||
74
day06.py
Normal file
74
day06.py
Normal file
@ -0,0 +1,74 @@
|
||||
from tools.aoc import AOCDay
|
||||
from tools.coordinate import Coordinate, DistanceAlgorithm
|
||||
from tools.grid import Grid
|
||||
from typing import Any, List
|
||||
|
||||
|
||||
def fill_space(grid: Grid, coords: List[Coordinate], distance: int, sizecounter: List[int]) -> int:
|
||||
filled = 0
|
||||
|
||||
for i, c in enumerate(coords):
|
||||
for t in c.getCircle(distance, False, *grid.getBoundaries()):
|
||||
if grid.get(t) == '.':
|
||||
for tc in coords:
|
||||
if tc != c and t.getDistanceTo(tc, DistanceAlgorithm.MANHATTAN, False) == distance:
|
||||
grid.set(t, False)
|
||||
break
|
||||
else:
|
||||
grid.set(t, i)
|
||||
sizecounter[i] += 1
|
||||
filled += 1
|
||||
|
||||
return filled
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(17, "test_input6_1"),
|
||||
(4771, "input6")
|
||||
],
|
||||
[
|
||||
(39149, "input6")
|
||||
]
|
||||
]
|
||||
|
||||
def get_input_coordinates(self) -> List[Coordinate]:
|
||||
return [Coordinate(x, y) for x, y in self.getInputAsArraySplit(", ", return_type=int)]
|
||||
|
||||
def part1(self) -> Any:
|
||||
coords = self.get_input_coordinates()
|
||||
grid = Grid(".")
|
||||
for i, c in enumerate(coords):
|
||||
grid.set(c, i)
|
||||
|
||||
size_counter = [0] * len(coords)
|
||||
fill_dist = 1
|
||||
while fill_space(grid, coords, fill_dist, size_counter) > 0:
|
||||
fill_dist += 1
|
||||
|
||||
return max(size_counter) + 1
|
||||
|
||||
def part2(self) -> Any:
|
||||
coords = self.get_input_coordinates()
|
||||
grid = Grid()
|
||||
for c in coords:
|
||||
grid.toggle(c)
|
||||
|
||||
region_size = 0
|
||||
for x in range(grid.minX, grid.maxX + 1):
|
||||
for y in range(grid.minY, grid.maxY + 1):
|
||||
this_dist_sum = 0
|
||||
for c in coords:
|
||||
this_dist_sum += Coordinate(x, y).getDistanceTo(c, DistanceAlgorithm.MANHATTAN, False)
|
||||
if this_dist_sum >= 10_000:
|
||||
break
|
||||
else:
|
||||
region_size += 1
|
||||
|
||||
return region_size
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 6)
|
||||
day.run(verbose=True)
|
||||
84
day07.py
Normal file
84
day07.py
Normal file
@ -0,0 +1,84 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
def get_available_steps(steps: dict) -> list:
|
||||
return [x for x in steps if len(steps[x]) == 0]
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
("CABDFE", "input7_test"),
|
||||
("JMQZELVYXTIGPHFNSOADKWBRUC", "input7"),
|
||||
],
|
||||
[
|
||||
(15, "input7_test"),
|
||||
(1133, "input7"),
|
||||
]
|
||||
]
|
||||
|
||||
def get_step_blocker(self) -> dict:
|
||||
steps = {}
|
||||
for line in self.getInput():
|
||||
tmp = line.split(" ")
|
||||
step_done, step_begin = tmp[1], tmp[7]
|
||||
if step_begin not in steps:
|
||||
steps[step_begin] = []
|
||||
if step_done not in steps:
|
||||
steps[step_done] = []
|
||||
|
||||
steps[step_begin].append(step_done)
|
||||
|
||||
return steps
|
||||
|
||||
def part1(self) -> Any:
|
||||
steps = self.get_step_blocker()
|
||||
step_order = ""
|
||||
while next_steps := get_available_steps(steps):
|
||||
next_step = min(next_steps)
|
||||
step_order += next_step
|
||||
del steps[next_step]
|
||||
for x in steps:
|
||||
if next_step in steps[x]:
|
||||
steps[x].remove(next_step)
|
||||
|
||||
return step_order
|
||||
|
||||
def part2(self) -> Any:
|
||||
steps = self.get_step_blocker()
|
||||
second = 0
|
||||
time_add = 0 if self._current_test_file.endswith("test") else 60
|
||||
worker_count = 2 if self._current_test_file.endswith("test") else 5
|
||||
step_order = ""
|
||||
current_work = []
|
||||
while second == 0 or current_work:
|
||||
new_work = []
|
||||
for work in current_work:
|
||||
if work[1] - 1 == 0:
|
||||
step_order += work[0]
|
||||
for x in steps:
|
||||
if work[0] in steps[x]:
|
||||
steps[x].remove(work[0])
|
||||
else:
|
||||
new_work.append([work[0], work[1] - 1])
|
||||
|
||||
current_work = new_work
|
||||
second += 1
|
||||
|
||||
if len(current_work) < worker_count:
|
||||
available_worker = worker_count - len(current_work)
|
||||
avaiable_work = get_available_steps(steps)
|
||||
while avaiable_work and available_worker:
|
||||
next_step = min(avaiable_work)
|
||||
del steps[next_step]
|
||||
avaiable_work.remove(next_step)
|
||||
current_work.append([next_step, ord(next_step) - 64 + time_add])
|
||||
available_worker -= 1
|
||||
|
||||
return second - 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 7)
|
||||
day.run(verbose=True)
|
||||
78
day08.py
Normal file
78
day08.py
Normal file
@ -0,0 +1,78 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Node:
|
||||
def __init__(self, data: list) -> None:
|
||||
self.metadata: list = data[-data[1]:]
|
||||
self.children: list = []
|
||||
|
||||
def get_metadata_sum(self):
|
||||
return sum(self.metadata) + sum(x.get_metadata_sum() for x in self.children)
|
||||
|
||||
def get_value(self):
|
||||
if not self.children:
|
||||
return sum(self.metadata)
|
||||
else:
|
||||
my_value = 0
|
||||
for x in self.metadata:
|
||||
if x - 1 < len(self.children):
|
||||
my_value += self.children[x - 1].get_value()
|
||||
|
||||
return my_value
|
||||
|
||||
def print(self, depth: int = 0):
|
||||
print(" " * depth, self.metadata)
|
||||
for x in self.children:
|
||||
x.print(depth + 2)
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(138, "input8_test"),
|
||||
(40746, "input8"),
|
||||
],
|
||||
[
|
||||
(66, "input8_test"),
|
||||
(37453, "input8"),
|
||||
]
|
||||
]
|
||||
|
||||
def get_node_tree(self) -> Node:
|
||||
inp = self.getInputAsArraySplit(' ', int)
|
||||
children = []
|
||||
while inp:
|
||||
index = 0
|
||||
parent_index = 0
|
||||
while index < len(inp) and inp[index]:
|
||||
if isinstance(inp[index], str):
|
||||
index += 1
|
||||
else:
|
||||
parent_index = index
|
||||
index += 2
|
||||
sub_children = []
|
||||
while index < len(inp) - 2 and str(inp[index + 2]).startswith("A"):
|
||||
try:
|
||||
sub_children.append(children[int(inp.pop(index + 2)[1:])])
|
||||
except IndexError:
|
||||
print(children, index)
|
||||
node = Node(inp[index:index+2+inp[index + 1]])
|
||||
node.children = sub_children
|
||||
children.append(node)
|
||||
inp[parent_index] -= 1
|
||||
inp = inp[:index] + ['A'+str(len(children) - 1)] + inp[index+2+inp[index + 1]:]
|
||||
if len(inp) == 1:
|
||||
del children
|
||||
return node
|
||||
|
||||
def part1(self) -> Any:
|
||||
return self.get_node_tree().get_metadata_sum()
|
||||
|
||||
def part2(self) -> Any:
|
||||
return self.get_node_tree().get_value()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 8)
|
||||
day.run(verbose=True)
|
||||
77
day09.py
Normal file
77
day09.py
Normal file
@ -0,0 +1,77 @@
|
||||
from collections import defaultdict
|
||||
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Marble:
|
||||
number: int
|
||||
left: 'Marble'
|
||||
right: 'Marble'
|
||||
|
||||
def __init__(self, number: int):
|
||||
self.number = number
|
||||
|
||||
|
||||
def play(players: int, marbles: int):
|
||||
current = Marble(0)
|
||||
current.left = current
|
||||
current.right = current
|
||||
|
||||
scores = defaultdict(int)
|
||||
|
||||
next_num = 1
|
||||
player = 0
|
||||
|
||||
while next_num <= marbles:
|
||||
this_marble = Marble(next_num)
|
||||
if next_num % 23 == 0:
|
||||
scores[player] = scores[player] + this_marble.number
|
||||
for _ in range(7):
|
||||
current = current.left
|
||||
scores[player] = scores[player] + current.number
|
||||
current.left.right = current.right
|
||||
current.right.left = current.left
|
||||
current = current.right
|
||||
else:
|
||||
current = current.right
|
||||
this_marble.left = current
|
||||
this_marble.right = current.right
|
||||
current.right.left = this_marble
|
||||
current.right = this_marble
|
||||
current = this_marble
|
||||
|
||||
player = (player + 1) % players
|
||||
next_num += 1
|
||||
|
||||
return max(scores.values())
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(8317, "input9_test1"),
|
||||
(146373, "input9_test2"),
|
||||
(412959, "input9"),
|
||||
],
|
||||
[
|
||||
(3333662986, "input9"),
|
||||
]
|
||||
]
|
||||
|
||||
def parse_input(self) -> (int, int):
|
||||
parts = self.getInput().split(" ")
|
||||
return int(parts[0]), int(parts[6])
|
||||
|
||||
def part1(self) -> Any:
|
||||
return play(*self.parse_input())
|
||||
|
||||
def part2(self) -> Any:
|
||||
players, marbles = self.parse_input()
|
||||
marbles *= 100
|
||||
return play(players, marbles)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 9)
|
||||
day.run(verbose=True)
|
||||
70
day10.py
Normal file
70
day10.py
Normal file
@ -0,0 +1,70 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
from tools.coordinate import Coordinate
|
||||
from tools.grid import Grid
|
||||
|
||||
|
||||
def simulate(starfield: Grid, print_grid: bool = True) -> int:
|
||||
minSteps = 1e9
|
||||
for pos in starfield.getActiveCells():
|
||||
vec = starfield.get(pos)[0]
|
||||
min_x_steps = abs(pos.x // vec.x) - 10
|
||||
min_y_stepd = abs(pos.y // vec.y) - 10
|
||||
minSteps = min(minSteps, min_x_steps, min_y_stepd)
|
||||
|
||||
new_starfield = Grid()
|
||||
for pos in starfield.getActiveCells():
|
||||
new_starfield.set(pos + starfield.get(pos)[0] * minSteps, starfield.get(pos))
|
||||
starfield = new_starfield
|
||||
|
||||
for i in range(20000):
|
||||
new_starfield = Grid()
|
||||
for pos in starfield.getActiveCells():
|
||||
for vec in starfield.get(pos):
|
||||
target = pos + vec
|
||||
if new_starfield.get(target):
|
||||
new_starfield.get(target).append(vec)
|
||||
else:
|
||||
new_starfield.set(target, [vec])
|
||||
starfield = new_starfield
|
||||
|
||||
if starfield.maxY - starfield.minY == 9:
|
||||
if print_grid:
|
||||
starfield.print(bool_mode=True)
|
||||
return i + 1 + minSteps
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
("BFFZCNXE", "input10"),
|
||||
],
|
||||
[
|
||||
(10391, "input10"),
|
||||
]
|
||||
]
|
||||
|
||||
def getInputGrid(self) -> Grid:
|
||||
grid = Grid()
|
||||
for line in self.getInput():
|
||||
(pos_str, vel_str) = line.split("> ")
|
||||
(pos_x, pos_y) = map(int, pos_str.split("<")[1].split(","))
|
||||
(vel_x, vel_y) = map(int, vel_str[:-1].split("<")[1].split(","))
|
||||
grid.set(Coordinate(pos_x, pos_y), [Coordinate(vel_x, vel_y)])
|
||||
|
||||
return grid
|
||||
|
||||
def part1(self) -> Any:
|
||||
starfield = self.getInputGrid()
|
||||
simulate(starfield)
|
||||
return "BFFZCNXE"
|
||||
|
||||
def part2(self) -> Any:
|
||||
starfield = self.getInputGrid()
|
||||
return simulate(starfield, print_grid=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 10)
|
||||
day.run(verbose=True)
|
||||
77
day11.py
Normal file
77
day11.py
Normal file
@ -0,0 +1,77 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
PRIMES = [2, 3, 5, 7, 11, 13, 17]
|
||||
|
||||
|
||||
def get_max_power_point(power_grid: list[list[int]], window_size: int = 3) -> (int, int, int):
|
||||
max_power_level = 0
|
||||
ret = (0, 0, 0)
|
||||
|
||||
for y in range(300 - window_size):
|
||||
for x in range(300 - window_size):
|
||||
sub_power_level = sum(
|
||||
sum(power_grid[z][x:x+window_size])
|
||||
for z in range(y, y + window_size)
|
||||
)
|
||||
if sub_power_level > max_power_level:
|
||||
max_power_level = sub_power_level
|
||||
ret = (x, y, max_power_level)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
("33,45", "input11_test"),
|
||||
("21,61", "input11_test2"),
|
||||
("243,34", "input11"),
|
||||
],
|
||||
[
|
||||
("90,269,16", "input11_test"),
|
||||
("232,251,12", "input11_test2"),
|
||||
("90,214,15", "input11"),
|
||||
]
|
||||
]
|
||||
|
||||
def get_power_grid(self) -> list[list[int]]:
|
||||
serial = self.getInput(return_type=int)
|
||||
grid = []
|
||||
for y in range(300):
|
||||
sub_grid = []
|
||||
for x in range(300):
|
||||
rack_id = x + 10
|
||||
power_level = rack_id * y
|
||||
power_level += serial
|
||||
power_level *= rack_id
|
||||
power_level = (power_level // 100) % 10
|
||||
power_level -= 5
|
||||
sub_grid.append(power_level)
|
||||
grid.append(sub_grid)
|
||||
|
||||
return grid
|
||||
|
||||
def part1(self) -> Any:
|
||||
power_grid = self.get_power_grid()
|
||||
return "%s,%s" % get_max_power_point(power_grid)[:-1]
|
||||
|
||||
def part2(self) -> Any:
|
||||
power_grid = self.get_power_grid()
|
||||
max_power_level = 0
|
||||
max_power_ret = (0, 0, 0)
|
||||
for i in range(2, 301):
|
||||
(x, y, max_power) = get_max_power_point(power_grid, i)
|
||||
if (x, y, max_power) == (0, 0, 0):
|
||||
break
|
||||
if max_power > max_power_level:
|
||||
max_power_level = max_power
|
||||
max_power_ret = (x, y, i)
|
||||
|
||||
return "%s,%s,%s" % max_power_ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2018, 11)
|
||||
day.run(verbose=True)
|
||||
352
inputs/input10
Normal file
352
inputs/input10
Normal file
@ -0,0 +1,352 @@
|
||||
position=< 31351, -51811> velocity=<-3, 5>
|
||||
position=< 21001, 31317> velocity=<-2, -3>
|
||||
position=<-41347, -41423> velocity=< 4, 4>
|
||||
position=<-20557, 52103> velocity=< 2, -5>
|
||||
position=<-30975, 41713> velocity=< 3, -4>
|
||||
position=< 10618, -20633> velocity=<-1, 2>
|
||||
position=< 31358, -10242> velocity=<-3, 1>
|
||||
position=< 10564, -10247> velocity=<-1, 1>
|
||||
position=<-20586, -31033> velocity=< 2, 3>
|
||||
position=< 10617, 52095> velocity=<-1, -5>
|
||||
position=<-30972, -51814> velocity=< 3, 5>
|
||||
position=< 21000, -10244> velocity=<-2, 1>
|
||||
position=<-30968, 20931> velocity=< 3, -2>
|
||||
position=<-20573, 20926> velocity=< 2, -2>
|
||||
position=<-10222, -41421> velocity=< 1, 4>
|
||||
position=< 10561, 10531> velocity=<-1, -1>
|
||||
position=<-10202, -31033> velocity=< 1, 3>
|
||||
position=<-31004, -20633> velocity=< 3, 2>
|
||||
position=<-51734, 10533> velocity=< 5, -1>
|
||||
position=<-10198, 10540> velocity=< 1, -1>
|
||||
position=< 52168, 20930> velocity=<-5, -2>
|
||||
position=<-31001, -31024> velocity=< 3, 3>
|
||||
position=<-10201, 52095> velocity=< 1, -5>
|
||||
position=< 52124, 20926> velocity=<-5, -2>
|
||||
position=<-20573, -20641> velocity=< 2, 2>
|
||||
position=<-10190, 20927> velocity=< 1, -2>
|
||||
position=< 52129, -31026> velocity=<-5, 3>
|
||||
position=< 10568, 31315> velocity=<-1, -3>
|
||||
position=< 52126, 41704> velocity=<-5, -4>
|
||||
position=<-20610, 52095> velocity=< 2, -5>
|
||||
position=< 10568, 10540> velocity=<-1, -1>
|
||||
position=<-30988, -20639> velocity=< 3, 2>
|
||||
position=< 31347, 10537> velocity=<-3, -1>
|
||||
position=< 10579, 20926> velocity=<-1, -2>
|
||||
position=<-20605, 31322> velocity=< 2, -3>
|
||||
position=< 31382, 31319> velocity=<-3, -3>
|
||||
position=< 20979, -20633> velocity=<-2, 2>
|
||||
position=<-30976, 20931> velocity=< 3, -2>
|
||||
position=< 20996, 10536> velocity=<-2, -1>
|
||||
position=< 10604, 10538> velocity=<-1, -1>
|
||||
position=<-20553, -31024> velocity=< 2, 3>
|
||||
position=<-41338, -10242> velocity=< 4, 1>
|
||||
position=< 41765, 41708> velocity=<-4, -4>
|
||||
position=< 21007, -31029> velocity=<-2, 3>
|
||||
position=< 41758, -20642> velocity=<-4, 2>
|
||||
position=<-51743, -41419> velocity=< 5, 4>
|
||||
position=<-10171, -41420> velocity=< 1, 4>
|
||||
position=< 31366, -51808> velocity=<-3, 5>
|
||||
position=<-51741, -20635> velocity=< 5, 2>
|
||||
position=< 10569, 41708> velocity=<-1, -4>
|
||||
position=< 41741, 52104> velocity=<-4, -5>
|
||||
position=< 52144, -20642> velocity=<-5, 2>
|
||||
position=< 41762, 10540> velocity=<-4, -1>
|
||||
position=< 41733, -31030> velocity=<-4, 3>
|
||||
position=< 31369, 10540> velocity=<-3, -1>
|
||||
position=<-10196, -41415> velocity=< 1, 4>
|
||||
position=< 31391, -20635> velocity=<-3, 2>
|
||||
position=< 21002, 31317> velocity=<-2, -3>
|
||||
position=<-51770, -31026> velocity=< 5, 3>
|
||||
position=<-20587, 10531> velocity=< 2, -1>
|
||||
position=< 31395, -10250> velocity=<-3, 1>
|
||||
position=< 41786, 41712> velocity=<-4, -4>
|
||||
position=< 41789, 20931> velocity=<-4, -2>
|
||||
position=< 20967, 52100> velocity=<-2, -5>
|
||||
position=< 10605, 31320> velocity=<-1, -3>
|
||||
position=< 10609, -20640> velocity=<-1, 2>
|
||||
position=< 52153, -20641> velocity=<-5, 2>
|
||||
position=<-31004, 20928> velocity=< 3, -2>
|
||||
position=< 41778, 31320> velocity=<-4, -3>
|
||||
position=<-41363, 52099> velocity=< 4, -5>
|
||||
position=< 41737, 31317> velocity=<-4, -3>
|
||||
position=< 41758, 52101> velocity=<-4, -5>
|
||||
position=<-51786, -51811> velocity=< 5, 5>
|
||||
position=< 21002, -31029> velocity=<-2, 3>
|
||||
position=< 41765, -31027> velocity=<-4, 3>
|
||||
position=<-20565, 52103> velocity=< 2, -5>
|
||||
position=< 21007, -10245> velocity=<-2, 1>
|
||||
position=< 52124, -10243> velocity=<-5, 1>
|
||||
position=< 41753, -41420> velocity=<-4, 4>
|
||||
position=<-51754, 20924> velocity=< 5, -2>
|
||||
position=<-30964, -51812> velocity=< 3, 5>
|
||||
position=< 41775, -20639> velocity=<-4, 2>
|
||||
position=< 31395, 41713> velocity=<-3, -4>
|
||||
position=< 21007, -10244> velocity=<-2, 1>
|
||||
position=< 10592, 20927> velocity=<-1, -2>
|
||||
position=<-41377, -10247> velocity=< 4, 1>
|
||||
position=<-20557, 10532> velocity=< 2, -1>
|
||||
position=< 41733, 20928> velocity=<-4, -2>
|
||||
position=<-51781, -10243> velocity=< 5, 1>
|
||||
position=< 10593, 41713> velocity=<-1, -4>
|
||||
position=<-41379, -10242> velocity=< 4, 1>
|
||||
position=<-51783, 31313> velocity=< 5, -3>
|
||||
position=<-41337, -41420> velocity=< 4, 4>
|
||||
position=<-41338, -20638> velocity=< 4, 2>
|
||||
position=< 41749, 52100> velocity=<-4, -5>
|
||||
position=< 52142, 52095> velocity=<-5, -5>
|
||||
position=< 10612, 10533> velocity=<-1, -1>
|
||||
position=< 31391, -51812> velocity=<-3, 5>
|
||||
position=< 52125, -41424> velocity=<-5, 4>
|
||||
position=< 10612, -41418> velocity=<-1, 4>
|
||||
position=< 31342, 20929> velocity=<-3, -2>
|
||||
position=<-51770, -20638> velocity=< 5, 2>
|
||||
position=< 41750, -10247> velocity=<-4, 1>
|
||||
position=< 20951, -10247> velocity=<-2, 1>
|
||||
position=<-20557, -10244> velocity=< 2, 1>
|
||||
position=<-41363, 20929> velocity=< 4, -2>
|
||||
position=< 41782, -20636> velocity=<-4, 2>
|
||||
position=< 41746, 52095> velocity=<-4, -5>
|
||||
position=< 10576, 52103> velocity=<-1, -5>
|
||||
position=<-10198, -31026> velocity=< 1, 3>
|
||||
position=< 31387, -10242> velocity=<-3, 1>
|
||||
position=<-51758, 41704> velocity=< 5, -4>
|
||||
position=< 52148, 52095> velocity=<-5, -5>
|
||||
position=<-31004, -10250> velocity=< 3, 1>
|
||||
position=<-41358, 20930> velocity=< 4, -2>
|
||||
position=<-41386, -31033> velocity=< 4, 3>
|
||||
position=< 31387, 10535> velocity=<-3, -1>
|
||||
position=<-30996, 52101> velocity=< 3, -5>
|
||||
position=< 10619, 20926> velocity=<-1, -2>
|
||||
position=< 41754, 41704> velocity=<-4, -4>
|
||||
position=<-41339, 31318> velocity=< 4, -3>
|
||||
position=< 41761, -31030> velocity=<-4, 3>
|
||||
position=<-20608, 31320> velocity=< 2, -3>
|
||||
position=< 10560, -31028> velocity=<-1, 3>
|
||||
position=<-30972, 41706> velocity=< 3, -4>
|
||||
position=< 21004, -51807> velocity=<-2, 5>
|
||||
position=< 52125, 41713> velocity=<-5, -4>
|
||||
position=<-41355, 41709> velocity=< 4, -4>
|
||||
position=< 52176, 20928> velocity=<-5, -2>
|
||||
position=<-10188, 10540> velocity=< 1, -1>
|
||||
position=<-20557, -31027> velocity=< 2, 3>
|
||||
position=< 52132, 52096> velocity=<-5, -5>
|
||||
position=< 52140, 20930> velocity=<-5, -2>
|
||||
position=< 10584, -10243> velocity=<-1, 1>
|
||||
position=<-30943, -51815> velocity=< 3, 5>
|
||||
position=<-30947, -31024> velocity=< 3, 3>
|
||||
position=< 31378, 52095> velocity=<-3, -5>
|
||||
position=<-20571, -10248> velocity=< 2, 1>
|
||||
position=< 20999, 31314> velocity=<-2, -3>
|
||||
position=<-30963, -51813> velocity=< 3, 5>
|
||||
position=< 31390, -41415> velocity=<-3, 4>
|
||||
position=<-20609, -41420> velocity=< 2, 4>
|
||||
position=< 10568, 31318> velocity=<-1, -3>
|
||||
position=< 31342, 20923> velocity=<-3, -2>
|
||||
position=< 31347, -20641> velocity=<-3, 2>
|
||||
position=<-10193, -20642> velocity=< 1, 2>
|
||||
position=<-41347, 10532> velocity=< 4, -1>
|
||||
position=<-41379, 10533> velocity=< 4, -1>
|
||||
position=< 20959, 20929> velocity=<-2, -2>
|
||||
position=< 52135, -20642> velocity=<-5, 2>
|
||||
position=< 41761, 31316> velocity=<-4, -3>
|
||||
position=<-20568, 10531> velocity=< 2, -1>
|
||||
position=<-10193, -20640> velocity=< 1, 2>
|
||||
position=<-41342, 41705> velocity=< 4, -4>
|
||||
position=<-20568, 41704> velocity=< 2, -4>
|
||||
position=< 41745, 10535> velocity=<-4, -1>
|
||||
position=<-20603, 10531> velocity=< 2, -1>
|
||||
position=< 52157, -10251> velocity=<-5, 1>
|
||||
position=< 52142, -10247> velocity=<-5, 1>
|
||||
position=< 10576, -31030> velocity=<-1, 3>
|
||||
position=< 41750, 52099> velocity=<-4, -5>
|
||||
position=< 31390, 10540> velocity=<-3, -1>
|
||||
position=<-51781, 41705> velocity=< 5, -4>
|
||||
position=< 10600, -10242> velocity=<-1, 1>
|
||||
position=< 41737, -20642> velocity=<-4, 2>
|
||||
position=<-41370, -41415> velocity=< 4, 4>
|
||||
position=< 20980, -10250> velocity=<-2, 1>
|
||||
position=< 21007, 31321> velocity=<-2, -3>
|
||||
position=< 10562, -20642> velocity=<-1, 2>
|
||||
position=<-30952, -41417> velocity=< 3, 4>
|
||||
position=<-31004, 52104> velocity=< 3, -5>
|
||||
position=< 52129, 10532> velocity=<-5, -1>
|
||||
position=<-51730, -41424> velocity=< 5, 4>
|
||||
position=<-20613, -51808> velocity=< 2, 5>
|
||||
position=<-10214, 41706> velocity=< 1, -4>
|
||||
position=<-41368, -20633> velocity=< 4, 2>
|
||||
position=< 31403, 31322> velocity=<-3, -3>
|
||||
position=< 52153, 20922> velocity=<-5, -2>
|
||||
position=<-51736, -41419> velocity=< 5, 4>
|
||||
position=< 10568, -20642> velocity=<-1, 2>
|
||||
position=< 41741, -20641> velocity=<-4, 2>
|
||||
position=< 41743, -10251> velocity=<-4, 1>
|
||||
position=<-30944, -31024> velocity=< 3, 3>
|
||||
position=< 20956, 10538> velocity=<-2, -1>
|
||||
position=<-41350, 20931> velocity=< 4, -2>
|
||||
position=<-30992, -51811> velocity=< 3, 5>
|
||||
position=<-31001, 31313> velocity=< 3, -3>
|
||||
position=< 20959, 41709> velocity=<-2, -4>
|
||||
position=<-10214, -41420> velocity=< 1, 4>
|
||||
position=<-51766, -20638> velocity=< 5, 2>
|
||||
position=< 52140, 20923> velocity=<-5, -2>
|
||||
position=< 31358, 31314> velocity=<-3, -3>
|
||||
position=< 20956, 31315> velocity=<-2, -3>
|
||||
position=< 41789, -31031> velocity=<-4, 3>
|
||||
position=<-20585, -41415> velocity=< 2, 4>
|
||||
position=< 31390, 10539> velocity=<-3, -1>
|
||||
position=< 31370, 20922> velocity=<-3, -2>
|
||||
position=<-30970, 31322> velocity=< 3, -3>
|
||||
position=< 41785, 31320> velocity=<-4, -3>
|
||||
position=<-10162, -41415> velocity=< 1, 4>
|
||||
position=<-20569, 31320> velocity=< 2, -3>
|
||||
position=< 52177, 41704> velocity=<-5, -4>
|
||||
position=< 21009, 31317> velocity=<-2, -3>
|
||||
position=< 31345, -41420> velocity=<-3, 4>
|
||||
position=<-41335, 52099> velocity=< 4, -5>
|
||||
position=<-51733, -20634> velocity=< 5, 2>
|
||||
position=<-41345, -51811> velocity=< 4, 5>
|
||||
position=<-41368, -20638> velocity=< 4, 2>
|
||||
position=<-10203, -41424> velocity=< 1, 4>
|
||||
position=<-20597, -51809> velocity=< 2, 5>
|
||||
position=<-51778, -41418> velocity=< 5, 4>
|
||||
position=< 31400, 41704> velocity=<-3, -4>
|
||||
position=< 41734, -31029> velocity=<-4, 3>
|
||||
position=< 52184, -31029> velocity=<-5, 3>
|
||||
position=< 20967, 41707> velocity=<-2, -4>
|
||||
position=<-51746, 31315> velocity=< 5, -3>
|
||||
position=< 10600, -41417> velocity=<-1, 4>
|
||||
position=< 41775, -31030> velocity=<-4, 3>
|
||||
position=< 21010, -41415> velocity=<-2, 4>
|
||||
position=<-10166, 41707> velocity=< 1, -4>
|
||||
position=< 52166, 41708> velocity=<-5, -4>
|
||||
position=<-41355, -31027> velocity=< 4, 3>
|
||||
position=<-20597, -31028> velocity=< 2, 3>
|
||||
position=< 31355, 31313> velocity=<-3, -3>
|
||||
position=<-30972, -41422> velocity=< 3, 4>
|
||||
position=<-51725, 20922> velocity=< 5, -2>
|
||||
position=< 31382, 20930> velocity=<-3, -2>
|
||||
position=<-30946, -51811> velocity=< 3, 5>
|
||||
position=< 52132, -20640> velocity=<-5, 2>
|
||||
position=<-10177, -51814> velocity=< 1, 5>
|
||||
position=< 10605, -20633> velocity=<-1, 2>
|
||||
position=< 31376, -20642> velocity=<-3, 2>
|
||||
position=<-20573, 52095> velocity=< 2, -5>
|
||||
position=<-41358, 52096> velocity=< 4, -5>
|
||||
position=<-10218, -41415> velocity=< 1, 4>
|
||||
position=< 52180, 31321> velocity=<-5, -3>
|
||||
position=< 10605, 20927> velocity=<-1, -2>
|
||||
position=<-20557, -41418> velocity=< 2, 4>
|
||||
position=< 52164, 20928> velocity=<-5, -2>
|
||||
position=< 10565, 10539> velocity=<-1, -1>
|
||||
position=< 31395, -51815> velocity=<-3, 5>
|
||||
position=< 20967, -20635> velocity=<-2, 2>
|
||||
position=< 20967, 10538> velocity=<-2, -1>
|
||||
position=< 10562, 10535> velocity=<-1, -1>
|
||||
position=<-20605, 20925> velocity=< 2, -2>
|
||||
position=<-30948, -31024> velocity=< 3, 3>
|
||||
position=<-10206, 52099> velocity=< 1, -5>
|
||||
position=<-10217, -51810> velocity=< 1, 5>
|
||||
position=< 10596, 10531> velocity=<-1, -1>
|
||||
position=< 20977, -51810> velocity=<-2, 5>
|
||||
position=<-10213, -10247> velocity=< 1, 1>
|
||||
position=< 31378, -10242> velocity=<-3, 1>
|
||||
position=< 10580, -51811> velocity=<-1, 5>
|
||||
position=<-30999, 41710> velocity=< 3, -4>
|
||||
position=<-41387, 31318> velocity=< 4, -3>
|
||||
position=< 31374, 52096> velocity=<-3, -5>
|
||||
position=< 52169, 10531> velocity=<-5, -1>
|
||||
position=<-30994, -31029> velocity=< 3, 3>
|
||||
position=< 41777, -41416> velocity=<-4, 4>
|
||||
position=< 21004, -31024> velocity=<-2, 3>
|
||||
position=< 41736, -20633> velocity=<-4, 2>
|
||||
position=< 10579, 20922> velocity=<-1, -2>
|
||||
position=<-41387, -51808> velocity=< 4, 5>
|
||||
position=<-20561, 10534> velocity=< 2, -1>
|
||||
position=<-51728, -31033> velocity=< 5, 3>
|
||||
position=< 31352, 20922> velocity=<-3, -2>
|
||||
position=<-30944, 41704> velocity=< 3, -4>
|
||||
position=< 52135, 41708> velocity=<-5, -4>
|
||||
position=<-30948, -10242> velocity=< 3, 1>
|
||||
position=<-20568, -41423> velocity=< 2, 4>
|
||||
position=< 41753, -31033> velocity=<-4, 3>
|
||||
position=< 31360, 52095> velocity=<-3, -5>
|
||||
position=<-41338, 31317> velocity=< 4, -3>
|
||||
position=< 20975, 20922> velocity=<-2, -2>
|
||||
position=< 20951, 41706> velocity=<-2, -4>
|
||||
position=<-51746, -20639> velocity=< 5, 2>
|
||||
position=< 10587, -10247> velocity=<-1, 1>
|
||||
position=<-51778, -20638> velocity=< 5, 2>
|
||||
position=<-51741, 20925> velocity=< 5, -2>
|
||||
position=< 10605, 41710> velocity=<-1, -4>
|
||||
position=<-51781, 52100> velocity=< 5, -5>
|
||||
position=< 10600, 31314> velocity=<-1, -3>
|
||||
position=<-51778, -31025> velocity=< 5, 3>
|
||||
position=<-51778, -41418> velocity=< 5, 4>
|
||||
position=< 10592, -10248> velocity=<-1, 1>
|
||||
position=<-10177, 20924> velocity=< 1, -2>
|
||||
position=<-10185, 31321> velocity=< 1, -3>
|
||||
position=< 20987, -41415> velocity=<-2, 4>
|
||||
position=<-10211, 52095> velocity=< 1, -5>
|
||||
position=< 20986, -10251> velocity=<-2, 1>
|
||||
position=<-10218, -41424> velocity=< 1, 4>
|
||||
position=<-10181, 31314> velocity=< 1, -3>
|
||||
position=<-51760, -31028> velocity=< 5, 3>
|
||||
position=< 41759, -41415> velocity=<-4, 4>
|
||||
position=<-30954, -51811> velocity=< 3, 5>
|
||||
position=<-31004, 20922> velocity=< 3, -2>
|
||||
position=< 52164, 52100> velocity=<-5, -5>
|
||||
position=<-30964, -31031> velocity=< 3, 3>
|
||||
position=< 31358, -41420> velocity=<-3, 4>
|
||||
position=< 52141, 41704> velocity=<-5, -4>
|
||||
position=< 10585, -51815> velocity=<-1, 5>
|
||||
position=<-20557, -51812> velocity=< 2, 5>
|
||||
position=<-10169, -10251> velocity=< 1, 1>
|
||||
position=< 10576, 52095> velocity=<-1, -5>
|
||||
position=<-10170, 41707> velocity=< 1, -4>
|
||||
position=< 31363, -41424> velocity=<-3, 4>
|
||||
position=<-41339, 20927> velocity=< 4, -2>
|
||||
position=<-30978, 52095> velocity=< 3, -5>
|
||||
position=<-51786, -10245> velocity=< 5, 1>
|
||||
position=<-41371, 31322> velocity=< 4, -3>
|
||||
position=<-30996, 20925> velocity=< 3, -2>
|
||||
position=< 31374, 20930> velocity=<-3, -2>
|
||||
position=< 52175, -10246> velocity=<-5, 1>
|
||||
position=< 31374, 41710> velocity=<-3, -4>
|
||||
position=<-10182, 52099> velocity=< 1, -5>
|
||||
position=<-10206, 41713> velocity=< 1, -4>
|
||||
position=<-20557, -31026> velocity=< 2, 3>
|
||||
position=< 31377, 52104> velocity=<-3, -5>
|
||||
position=< 10608, -41424> velocity=<-1, 4>
|
||||
position=<-30964, -20638> velocity=< 3, 2>
|
||||
position=<-51741, -10243> velocity=< 5, 1>
|
||||
position=< 52156, 31321> velocity=<-5, -3>
|
||||
position=< 31354, 31313> velocity=<-3, -3>
|
||||
position=< 20980, 20922> velocity=<-2, -2>
|
||||
position=<-20556, -10242> velocity=< 2, 1>
|
||||
position=< 52129, -20636> velocity=<-5, 2>
|
||||
position=< 20976, 41704> velocity=<-2, -4>
|
||||
position=<-10198, 41712> velocity=< 1, -4>
|
||||
position=< 31394, -41417> velocity=<-3, 4>
|
||||
position=<-20573, 52098> velocity=< 2, -5>
|
||||
position=<-41350, 20928> velocity=< 4, -2>
|
||||
position=< 52156, 10532> velocity=<-5, -1>
|
||||
position=<-31002, 20926> velocity=< 3, -2>
|
||||
position=<-30999, 10534> velocity=< 3, -1>
|
||||
position=< 52177, 52104> velocity=<-5, -5>
|
||||
position=<-30978, 31322> velocity=< 3, -3>
|
||||
position=<-30959, 31318> velocity=< 3, -3>
|
||||
position=<-51741, -31031> velocity=< 5, 3>
|
||||
position=< 31344, -10242> velocity=<-3, 1>
|
||||
position=<-41386, -10251> velocity=< 4, 1>
|
||||
position=< 41738, -10243> velocity=<-4, 1>
|
||||
position=< 41778, -10245> velocity=<-4, 1>
|
||||
position=< 41774, -41422> velocity=<-4, 4>
|
||||
position=<-10166, 20927> velocity=< 1, -2>
|
||||
position=< 21011, 41708> velocity=<-2, -4>
|
||||
position=<-30988, -31027> velocity=< 3, 3>
|
||||
position=<-41339, -51815> velocity=< 4, 5>
|
||||
position=< 31385, -10245> velocity=<-3, 1>
|
||||
position=<-41369, 52095> velocity=< 4, -5>
|
||||
position=< 52129, 10533> velocity=<-5, -1>
|
||||
position=< 21010, -41424> velocity=<-2, 4>
|
||||
position=<-30964, 10533> velocity=< 3, -1>
|
||||
31
inputs/input10_test
Normal file
31
inputs/input10_test
Normal file
@ -0,0 +1,31 @@
|
||||
position=< 9, 1> velocity=< 0, 2>
|
||||
position=< 7, 0> velocity=<-1, 0>
|
||||
position=< 3, -2> velocity=<-1, 1>
|
||||
position=< 6, 10> velocity=<-2, -1>
|
||||
position=< 2, -4> velocity=< 2, 2>
|
||||
position=<-6, 10> velocity=< 2, -2>
|
||||
position=< 1, 8> velocity=< 1, -1>
|
||||
position=< 1, 7> velocity=< 1, 0>
|
||||
position=<-3, 11> velocity=< 1, -2>
|
||||
position=< 7, 6> velocity=<-1, -1>
|
||||
position=<-2, 3> velocity=< 1, 0>
|
||||
position=<-4, 3> velocity=< 2, 0>
|
||||
position=<10, -3> velocity=<-1, 1>
|
||||
position=< 5, 11> velocity=< 1, -2>
|
||||
position=< 4, 7> velocity=< 0, -1>
|
||||
position=< 8, -2> velocity=< 0, 1>
|
||||
position=<15, 0> velocity=<-2, 0>
|
||||
position=< 1, 6> velocity=< 1, 0>
|
||||
position=< 8, 9> velocity=< 0, -1>
|
||||
position=< 3, 3> velocity=<-1, 1>
|
||||
position=< 0, 5> velocity=< 0, -1>
|
||||
position=<-2, 2> velocity=< 2, 0>
|
||||
position=< 5, -2> velocity=< 1, 2>
|
||||
position=< 1, 4> velocity=< 2, 1>
|
||||
position=<-2, 7> velocity=< 2, -2>
|
||||
position=< 3, 6> velocity=<-1, -1>
|
||||
position=< 5, 0> velocity=< 1, 0>
|
||||
position=<-6, 0> velocity=< 2, 0>
|
||||
position=< 5, 9> velocity=< 1, -2>
|
||||
position=<14, 7> velocity=<-2, 0>
|
||||
position=<-3, 6> velocity=< 2, -1>
|
||||
1
inputs/input11
Normal file
1
inputs/input11
Normal file
@ -0,0 +1 @@
|
||||
1718
|
||||
1
inputs/input11_test
Normal file
1
inputs/input11_test
Normal file
@ -0,0 +1 @@
|
||||
18
|
||||
1
inputs/input11_test2
Normal file
1
inputs/input11_test2
Normal file
@ -0,0 +1 @@
|
||||
42
|
||||
250
inputs/input2
Normal file
250
inputs/input2
Normal file
@ -0,0 +1,250 @@
|
||||
cnjxpritdzhubeseewfmqagkul
|
||||
cwyxpgitdzhvbosyewfmqagkul
|
||||
cnfxpritdzhebosywwfmqagkul
|
||||
cnjxpritdzgvbosyawfiqagkul
|
||||
cnkxpritdzhvbosyewfmgagkuh
|
||||
gnjxprhtdzhebosyewfmqagkul
|
||||
cnjxpriedzevbosyewfjqagkul
|
||||
cnjxpritdzhpyosyewfsqagkul
|
||||
cnjxprltdzhvbosyewfmhagkzl
|
||||
cnjxfritdjhvbosyewfmiagkul
|
||||
xnjxpritdzhvbosyewfmqagkgn
|
||||
cnjxpritdzmvzosyewfhqagkul
|
||||
cljxxritdzhvbosyewfmragkul
|
||||
cnjxjritdzhvbovyewfmvagkul
|
||||
cnjxprdtdzhpbosyewvmqagkul
|
||||
cojxprdtdzhzbosyewfmqagkul
|
||||
cnjxpritgzhvfgsyewfmqagkul
|
||||
knjxprptdzhvbosyecfmqagkul
|
||||
cnjxpritdzhvbvsyeyfmqagkuc
|
||||
cnjxpritdzhvbosvewfmoagjul
|
||||
cnjxpritdzhvbosyfwfmbagkjl
|
||||
cnjxpjitazhvbosfewfmqagkul
|
||||
cnjtpfitdzhvbosyewfmiagkul
|
||||
ckjxpritdzhvbysyewfmqagoul
|
||||
cnjxvritdzhvbfsyewfmqalkul
|
||||
cnjipqitdzhvbosyewfeqagkul
|
||||
cnjhpritdzhvbosyewymqjgkul
|
||||
cnjxprrtdzhvbosyewfmlkgkul
|
||||
cnjxnritdzhvbopyewfmqaskul
|
||||
cxjxpritdzhvtosyewjmqagkul
|
||||
cnjxpritdzhvbjsyewfrqagkwl
|
||||
cnjxhritdzhubosyewfmqagvul
|
||||
cnjxpritdzhvbosyyyfmeagkul
|
||||
cnjxkritdzhvaoeyewfmqagkul
|
||||
cnjxpritdzhvtotyewfmqazkul
|
||||
cnjxoriadzhvbosyewfmqcgkul
|
||||
cnjxpritdzhcbosyewfmkapkul
|
||||
fnjxprtddzhvbosyewfmqagkul
|
||||
cnjxmvitdzhvbosyewfmqagrul
|
||||
cnjxpyitdzhibosyewfmqagktl
|
||||
cyjxprxtdzhvbosyewbmqagkul
|
||||
onjxpditdzhvbosyeofmqagkul
|
||||
cnjxprixdzhvbosuewftqagkul
|
||||
cnjxpritdrhvaosyewymqagkul
|
||||
cnjxpritdzhhbokyewfvqagkul
|
||||
cnjxpritczhvbosyewfmqwgxul
|
||||
cnjxpribdzqvbnsyewfmqagkul
|
||||
ynpxpritdzhvbvsyewfmqagkul
|
||||
cnjxprirdzhvboerewfmqagkul
|
||||
cnjxpritdxhvbosyewfmgavkul
|
||||
cnwxprntdzhvbosyewfmqagkuk
|
||||
cnjxpritzzhvbosyewfmcagktl
|
||||
bbjxpritdzhvbosyetfmqagkul
|
||||
cnjxpbitdzhvbosyewrmqagkui
|
||||
cnjxwrildzcvbosyewfmqagkul
|
||||
cnqxpoitdzhvbosnewfmqagkul
|
||||
cnzxpritdzhvbosyewfmqazkfl
|
||||
cnjxpriddzhvoosyewfmhagkul
|
||||
znjxpritdzhvbosjewfmqagkur
|
||||
cnjxpritdzhvbosyewcmfagkuk
|
||||
cnjxpritdzhvbomyywnmqagkul
|
||||
cnjxpgitjzhvbosyejfmqagkul
|
||||
cnjxpkitdzjvbosyewfmqcgkul
|
||||
cnjxpritduhvbosyewfmqfkkul
|
||||
cnfxpritdzhvbgsyewfmqwgkul
|
||||
cnjxpritdzhvbosywufmqaskul
|
||||
cnjxprittzhvboryswfmqagkul
|
||||
cndxpritpzrvbosyewfmqagkul
|
||||
cnjxpritdzhvbosyewfwqazkum
|
||||
cccxprmtdzhvbosyewfmqagkul
|
||||
cnjxpzitdzhvlbsyewfmqagkul
|
||||
cnjxdrigdzhvbosyewfmqagsul
|
||||
fhjxpritdzhvbosyewfmqagkcl
|
||||
cnjxpritdzhvdosyewffqagaul
|
||||
cnjxprikdztvbosyekfmqagkul
|
||||
cnjxpritdzhvbohiewfmqagkue
|
||||
cnjxpritdzhvbowyetfmqegkul
|
||||
cnuxpritdzhvbosyewmmqapkul
|
||||
qnjxpritdzhvbosyewfmjakkul
|
||||
cnjxpritdzlvbosyewiaqagkul
|
||||
cnjxpritdzhpoosyewfmvagkul
|
||||
cdjxpritdzhvboryewfbqagkul
|
||||
cnjxppitxzhvbosyewymqagkul
|
||||
cnjxpywtdzhvboiyewfmqagkul
|
||||
cnjxpritdzpvbosyezfmqaqkul
|
||||
cnjppritdghvbosyewfdqagkul
|
||||
cmjxpritdzhvbosvewfmqagkup
|
||||
cnjxoritdzhvbosylffmqagkul
|
||||
cnjxfritdzhvbojyewfmqagkvl
|
||||
cnjxpritdzhvbozyewgmqlgkul
|
||||
cnjxlritdzhvbosyewfmqalkug
|
||||
cnyxprittzhvbosyewfmsagkul
|
||||
cnjxprytdzcvdosyewfmqagkul
|
||||
ctjxpritdzhvbosyedfmqagkil
|
||||
cnjxpvitdzhrbosyewfmqaekul
|
||||
cnyxyritdzhvbospewfmqagkul
|
||||
cnjxoritwzhvbosyewrmqhgkul
|
||||
cnjxpritdzhjbosyqwsmqagkul
|
||||
cnjzprindzhvbosyewfmqabkul
|
||||
cnjspritdzhvbosysffmqagkul
|
||||
cnxxpritdzhvbosyelfmqageul
|
||||
bnjhpritdzhvbosyewfmzagkul
|
||||
cnjxbhitdzhdbosyewfmqagkul
|
||||
cnjxprktdzmvbosyewfmqagkuj
|
||||
cnjxprixdzhvbqsyewfmqmgkul
|
||||
cnjxpkitdzhvbosyewfmqagbum
|
||||
cnjhpritdzhxbosyewfmqagjul
|
||||
cnjxpritdzzvbosyewuqqagkul
|
||||
cnjxprhtdzhvuopyewfmqagkul
|
||||
cnjxpritdzhjqosyewfmqagkgl
|
||||
cnzxpritdzhvbosyejfmuagkul
|
||||
cnvxpritoohvbosyewfmqagkul
|
||||
cnjxpmitdzwvbosyemfmqagkul
|
||||
cnjoprittzzvbosyewfmqagkul
|
||||
cnjxpgitdzhvbosytwfmqsgkul
|
||||
cnjxprrtdehvbosyewfnqagkul
|
||||
onjxpjitdzgvbosyewfmqagkul
|
||||
cnjxpmitdzhvbopaewfmqagkul
|
||||
cnjxpritqzhvbosoewfrqagkul
|
||||
cnjxpnitdzhvbosyewfmqagkjy
|
||||
cnsxpritdzhvbosyewfmqjykul
|
||||
cnjxpriidzhvbosyewfmqxgkut
|
||||
cnjxpyitdzhnbosyewfgqagkul
|
||||
cnjxpritdzhbboyyewfmqagsul
|
||||
cnjxpeitdzsvbosyewfmqabkul
|
||||
cnjxpritdzhzvosyewfmragkul
|
||||
cnjrpritdzhmbosyewfmqrgkul
|
||||
cnjxpritdzhmbosyenfmqaglul
|
||||
cnjxqrntdzhvboswewfmqagkul
|
||||
cnjxprdtpzhvbosyewfmqagkcl
|
||||
cnjxpritdzhvsdsyewfmqagkur
|
||||
cnjxpritdzhvvosyewumqhgkul
|
||||
cnzxpritdznvhosyewfmqagkul
|
||||
ynjypritdzhvbosyewfmqagkuz
|
||||
cnjxpnitdzhvbocyezfmqagkul
|
||||
vnjxpritdzhvbfsyewfmjagkul
|
||||
cnjfpritdzhvbosyewfmqagkzu
|
||||
cnjxpritdzhbbosyewfmlegkul
|
||||
cnjxpnitdzhvbosyesfmbagkul
|
||||
cnjxpritezwvbosyewfmqagkgl
|
||||
cujxpritdzhqbosyawfmqagkul
|
||||
cnjxprindzhrbosyerfmqagkul
|
||||
cntxpritdzhvbosyewfmqauxul
|
||||
cnjxpvitdzhvbosyepfmqagkuy
|
||||
cnjxdrqtdzhvbosdewfmqagkul
|
||||
cnnxpritdzhvvosyenfmqagkul
|
||||
lnjxphitdzhvbosyewfaqagkul
|
||||
cngxpritdzhhbobyewfmqagkul
|
||||
uncxphitdzhvbosyewfmqagkul
|
||||
cnjxpribdehvbosfewfmqagkul
|
||||
cnjxppitdqhvbmsyewfmqagkul
|
||||
gnjxpritkzhvbosyewfbqagkul
|
||||
znjxpritdzhvbowycwfmqagkul
|
||||
cnjxpgitdzhvbosyewidqagkul
|
||||
cnjxhritdzhvbowyswfmqagkul
|
||||
injxkritdzhvbjsyewfmqagkul
|
||||
cmjupritgzhvbosyewfmqagkul
|
||||
cnjxpritdzbvjoeyewfmqagkul
|
||||
cnjxpritdkhvbosyewlmuagkul
|
||||
cnkxpritdzhebvsyewfmqagkul
|
||||
cyjxptitdzhvbosyewfmqagkuv
|
||||
cnjxpritdzhvbodrewflqagkul
|
||||
cnjxpratdzhvbksyewfhqagkul
|
||||
cnjxpoitdzhvbosjewxmqagkul
|
||||
cnjxprhidzhvbasyewfmqagkul
|
||||
cnjxpritdzhvbosqewvmqagmul
|
||||
cnjxoritdzhvbosyzifmqagkul
|
||||
mnjxpritdzhvbcsyeyfmqagkul
|
||||
cnjhpritgzhvbosyewfmqngkul
|
||||
cnjxprijdzevbesyewfmqagkul
|
||||
cnexprqtdzhvbosyewvmqagkul
|
||||
cnjxpxitdzhvbosyawfmqmgkul
|
||||
cnjxpritdzhvbosyirfmqaxkul
|
||||
cqjxpcitdzhvboslewfmqagkul
|
||||
cmjxpqitdztvbosyewfmqagkul
|
||||
cnbxpritdzhvfosyewfmuagkul
|
||||
cnjxprrtdzhvbosumwfmqagkul
|
||||
cnjxprttdvhvbossewfmqagkul
|
||||
cnjxpritdzhvbcsuewfaqagkul
|
||||
cbjxpritdzhvbosyewfhqalkul
|
||||
cnjxprithzhvbosjcwfmqagkul
|
||||
chjxpritdzhvbosyewftcagkul
|
||||
cnjxprirdchvdosyewfmqagkul
|
||||
cnjxpritdxhvbosyewfmqcgkal
|
||||
cnjxpriidchvbosrewfmqagkul
|
||||
cnjhprizdzhvbosyewfmqagvul
|
||||
cnjwpritdzhpbosyewfmqaqkul
|
||||
cnjxpgitfzhvbosyxwfmqagkul
|
||||
cnjxpjiedzhvbosywwfmqagkul
|
||||
cnjxpritdzhvbosyewfpqynkul
|
||||
xnixlritdzhvbosyewfmqagkul
|
||||
cnjxoritdznvbosyehfmqagkul
|
||||
cnjxpritdzhvbjsyewsmqagcul
|
||||
lnjxpritdzhvkosyewjmqagkul
|
||||
cnjxpritdzhvbosyedfiqvgkul
|
||||
cnjxpritdzhqbdsyerfmqagkul
|
||||
cnjxpritdzavbosyywfmqagvul
|
||||
dmjxprithzhvbosyewfmqagkul
|
||||
cnjxpriqdzhvnosyeofmqagkul
|
||||
cnjxpritdxhvboszewfmqkgkul
|
||||
cnjxpritdzxvbosjewymqagkul
|
||||
cnjxpritdzngbosyewfmqugkul
|
||||
cajxpritdnhvbosyerfmqagkul
|
||||
cnsxpritdzhvbosymwfmqagcul
|
||||
cnjxoritdzhvbosyewrmqhgkul
|
||||
cnjxpritdzhvposyewfmqagkwo
|
||||
cnjxpriazzhvbosyeufmqagkul
|
||||
cnjxrritdzhvbosymhfmqagkul
|
||||
cnjxprztdzhvbosyewfmqtgkum
|
||||
cnjxpritdzhvbmsyewfmqatkun
|
||||
cnuxpritdzhvbosyewfmqagvur
|
||||
ctjxxritdzhvbosyewfvqagkul
|
||||
cnjxpritdzlvbosyevfmqagkll
|
||||
cnjxpritdzhlbosyewfmqagasl
|
||||
cnjxpritwzhvbosyewfcxagkul
|
||||
cyjxpritdzhfbosyewfmqagcul
|
||||
cnjxpritxghvkosyewfmqagkul
|
||||
ctjxpritdjhvbosyewfmqkgkul
|
||||
cnjxpritxzhvbosyewjmbagkul
|
||||
unjxpritdzhkbosyewfmqaghul
|
||||
cnjoprqtdzhvbosyewzmqagkul
|
||||
rnjxprgtgzhvbosyewfmqagkul
|
||||
cnjgpqitdzhvbosyewfaqagkul
|
||||
cnjxpritdzuybosyewfmqagful
|
||||
cnjxprqtdahvbosyewfnqagkul
|
||||
cnjxpritdzhmkhsyewfmqagkul
|
||||
wnjxpritdzhvbosiewfmqagkml
|
||||
cnjmpritdzhvbosyjwfmqagkdl
|
||||
cnjopritdzhvbksyewfmqrgkul
|
||||
cnlxpritdzhvbosyewfmomgkul
|
||||
cgjxpritdzhvbbsyewfmxagkul
|
||||
cnaxpritdvhvnosyewfmqagkul
|
||||
cnjxprijdzhvbkmyewfmqagkul
|
||||
cnjxpritdzhvposyewzmqagkuz
|
||||
cnuxpuitdzdvbosyewfmqagkul
|
||||
cnjxprifdzjvbosyewfyqagkul
|
||||
cnhspritdzhvbosyewfmqaghul
|
||||
cnjxprcbdzfvbosyewfmqagkul
|
||||
lnjapritdzhvbosyewfmqegkul
|
||||
cnjxprisszhvbosyewqmqagkul
|
||||
cnjxpritdzhvbosyeifmsagoul
|
||||
cnjxpritrfhvbosyewfmqagkuz
|
||||
cnjxkritdzmvboqyewfmqagkul
|
||||
cnjxpritdzhvbosyedfmqzgkzl
|
||||
cnjxprifdzhvbosyswfmqagksl
|
||||
cnjxoritdzhvbosyxwfmhagkul
|
||||
cnjhpritdzzvbosfewfmqagkul
|
||||
cnjxprityjhvbomyewfmqagkul
|
||||
cnjbpritdzhvbosyywfmqagkuf
|
||||
cnjxprrtdzhvbosyewgmqagtul
|
||||
1409
inputs/input3
Normal file
1409
inputs/input3
Normal file
File diff suppressed because it is too large
Load Diff
1044
inputs/input4
Normal file
1044
inputs/input4
Normal file
File diff suppressed because it is too large
Load Diff
1
inputs/input5
Normal file
1
inputs/input5
Normal file
File diff suppressed because one or more lines are too long
50
inputs/input6
Normal file
50
inputs/input6
Normal file
@ -0,0 +1,50 @@
|
||||
260, 78
|
||||
42, 40
|
||||
87, 276
|
||||
219, 124
|
||||
166, 137
|
||||
341, 138
|
||||
82, 121
|
||||
114, 174
|
||||
218, 289
|
||||
61, 358
|
||||
328, 164
|
||||
279, 50
|
||||
218, 107
|
||||
273, 320
|
||||
192, 349
|
||||
354, 103
|
||||
214, 175
|
||||
128, 196
|
||||
237, 67
|
||||
333, 150
|
||||
98, 260
|
||||
166, 217
|
||||
92, 212
|
||||
55, 165
|
||||
205, 138
|
||||
321, 199
|
||||
285, 148
|
||||
217, 130
|
||||
357, 319
|
||||
160, 67
|
||||
63, 75
|
||||
345, 123
|
||||
316, 220
|
||||
41, 253
|
||||
240, 245
|
||||
201, 124
|
||||
336, 166
|
||||
95, 301
|
||||
55, 181
|
||||
219, 315
|
||||
209, 237
|
||||
317, 254
|
||||
314, 300
|
||||
242, 295
|
||||
295, 293
|
||||
285, 263
|
||||
330, 204
|
||||
112, 106
|
||||
348, 49
|
||||
81, 185
|
||||
101
inputs/input7
Normal file
101
inputs/input7
Normal file
@ -0,0 +1,101 @@
|
||||
Step Z must be finished before step V can begin.
|
||||
Step V must be finished before step K can begin.
|
||||
Step M must be finished before step Q can begin.
|
||||
Step E must be finished before step X can begin.
|
||||
Step J must be finished before step W can begin.
|
||||
Step L must be finished before step O can begin.
|
||||
Step Q must be finished before step T can begin.
|
||||
Step Y must be finished before step P can begin.
|
||||
Step X must be finished before step R can begin.
|
||||
Step T must be finished before step U can begin.
|
||||
Step I must be finished before step O can begin.
|
||||
Step P must be finished before step H can begin.
|
||||
Step G must be finished before step A can begin.
|
||||
Step N must be finished before step A can begin.
|
||||
Step H must be finished before step B can begin.
|
||||
Step F must be finished before step D can begin.
|
||||
Step S must be finished before step O can begin.
|
||||
Step O must be finished before step W can begin.
|
||||
Step D must be finished before step U can begin.
|
||||
Step W must be finished before step B can begin.
|
||||
Step A must be finished before step K can begin.
|
||||
Step B must be finished before step R can begin.
|
||||
Step K must be finished before step C can begin.
|
||||
Step R must be finished before step C can begin.
|
||||
Step U must be finished before step C can begin.
|
||||
Step A must be finished before step U can begin.
|
||||
Step J must be finished before step I can begin.
|
||||
Step D must be finished before step K can begin.
|
||||
Step V must be finished before step S can begin.
|
||||
Step H must be finished before step C can begin.
|
||||
Step R must be finished before step U can begin.
|
||||
Step I must be finished before step G can begin.
|
||||
Step D must be finished before step R can begin.
|
||||
Step M must be finished before step B can begin.
|
||||
Step G must be finished before step R can begin.
|
||||
Step M must be finished before step I can begin.
|
||||
Step G must be finished before step N can begin.
|
||||
Step M must be finished before step N can begin.
|
||||
Step Q must be finished before step S can begin.
|
||||
Step I must be finished before step S can begin.
|
||||
Step J must be finished before step R can begin.
|
||||
Step O must be finished before step B can begin.
|
||||
Step G must be finished before step S can begin.
|
||||
Step J must be finished before step C can begin.
|
||||
Step M must be finished before step D can begin.
|
||||
Step T must be finished before step H can begin.
|
||||
Step P must be finished before step N can begin.
|
||||
Step S must be finished before step K can begin.
|
||||
Step T must be finished before step C can begin.
|
||||
Step J must be finished before step A can begin.
|
||||
Step G must be finished before step F can begin.
|
||||
Step N must be finished before step R can begin.
|
||||
Step N must be finished before step W can begin.
|
||||
Step T must be finished before step I can begin.
|
||||
Step S must be finished before step B can begin.
|
||||
Step H must be finished before step F can begin.
|
||||
Step B must be finished before step C can begin.
|
||||
Step L must be finished before step W can begin.
|
||||
Step N must be finished before step O can begin.
|
||||
Step O must be finished before step A can begin.
|
||||
Step H must be finished before step S can begin.
|
||||
Step F must be finished before step A can begin.
|
||||
Step F must be finished before step C can begin.
|
||||
Step M must be finished before step A can begin.
|
||||
Step Z must be finished before step H can begin.
|
||||
Step Z must be finished before step L can begin.
|
||||
Step E must be finished before step H can begin.
|
||||
Step X must be finished before step T can begin.
|
||||
Step Y must be finished before step X can begin.
|
||||
Step E must be finished before step W can begin.
|
||||
Step P must be finished before step R can begin.
|
||||
Step Z must be finished before step E can begin.
|
||||
Step W must be finished before step C can begin.
|
||||
Step I must be finished before step P can begin.
|
||||
Step X must be finished before step A can begin.
|
||||
Step Y must be finished before step C can begin.
|
||||
Step I must be finished before step F can begin.
|
||||
Step L must be finished before step T can begin.
|
||||
Step A must be finished before step B can begin.
|
||||
Step F must be finished before step W can begin.
|
||||
Step T must be finished before step R can begin.
|
||||
Step X must be finished before step F can begin.
|
||||
Step M must be finished before step O can begin.
|
||||
Step N must be finished before step K can begin.
|
||||
Step T must be finished before step S can begin.
|
||||
Step J must be finished before step N can begin.
|
||||
Step J must be finished before step S can begin.
|
||||
Step O must be finished before step D can begin.
|
||||
Step T must be finished before step P can begin.
|
||||
Step Z must be finished before step D can begin.
|
||||
Step L must be finished before step X can begin.
|
||||
Step Q must be finished before step G can begin.
|
||||
Step M must be finished before step G can begin.
|
||||
Step P must be finished before step W can begin.
|
||||
Step V must be finished before step P can begin.
|
||||
Step D must be finished before step B can begin.
|
||||
Step Y must be finished before step D can begin.
|
||||
Step X must be finished before step S can begin.
|
||||
Step K must be finished before step U can begin.
|
||||
Step Z must be finished before step Y can begin.
|
||||
Step D must be finished before step W can begin.
|
||||
7
inputs/input7_test
Normal file
7
inputs/input7_test
Normal file
@ -0,0 +1,7 @@
|
||||
Step C must be finished before step A can begin.
|
||||
Step C must be finished before step F can begin.
|
||||
Step A must be finished before step B can begin.
|
||||
Step A must be finished before step D can begin.
|
||||
Step B must be finished before step E can begin.
|
||||
Step D must be finished before step E can begin.
|
||||
Step F must be finished before step E can begin.
|
||||
1
inputs/input8
Normal file
1
inputs/input8
Normal file
File diff suppressed because one or more lines are too long
1
inputs/input8_test
Normal file
1
inputs/input8_test
Normal file
@ -0,0 +1 @@
|
||||
2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2
|
||||
1
inputs/input9
Normal file
1
inputs/input9
Normal file
@ -0,0 +1 @@
|
||||
435 players; last marble is worth 71184 points
|
||||
1
inputs/input9_test1
Normal file
1
inputs/input9_test1
Normal file
@ -0,0 +1 @@
|
||||
10 players; last marble is worth 1618 points
|
||||
1
inputs/input9_test2
Normal file
1
inputs/input9_test2
Normal file
@ -0,0 +1 @@
|
||||
13 players; last marble is worth 7999 points
|
||||
7
inputs/test_input2
Normal file
7
inputs/test_input2
Normal file
@ -0,0 +1,7 @@
|
||||
abcdef
|
||||
bababc
|
||||
abbcde
|
||||
abcccd
|
||||
aabcdd
|
||||
abcdee
|
||||
ababab
|
||||
7
inputs/test_input2_1
Normal file
7
inputs/test_input2_1
Normal file
@ -0,0 +1,7 @@
|
||||
abcdef
|
||||
bababc
|
||||
abbcde
|
||||
abcccd
|
||||
aabcdd
|
||||
abcdee
|
||||
ababab
|
||||
7
inputs/test_input2_2
Normal file
7
inputs/test_input2_2
Normal file
@ -0,0 +1,7 @@
|
||||
abcde
|
||||
fghij
|
||||
klmno
|
||||
pqrst
|
||||
fguij
|
||||
axcye
|
||||
wvxyz
|
||||
3
inputs/test_input3
Normal file
3
inputs/test_input3
Normal file
@ -0,0 +1,3 @@
|
||||
#1 @ 1,3: 4x4
|
||||
#2 @ 3,1: 4x4
|
||||
#3 @ 5,5: 2x2
|
||||
17
inputs/test_input4_1
Normal file
17
inputs/test_input4_1
Normal file
@ -0,0 +1,17 @@
|
||||
[1518-11-01 00:00] Guard #10 begins shift
|
||||
[1518-11-01 00:05] falls asleep
|
||||
[1518-11-01 00:25] wakes up
|
||||
[1518-11-01 00:30] falls asleep
|
||||
[1518-11-01 00:55] wakes up
|
||||
[1518-11-01 23:58] Guard #99 begins shift
|
||||
[1518-11-02 00:40] falls asleep
|
||||
[1518-11-02 00:50] wakes up
|
||||
[1518-11-03 00:05] Guard #10 begins shift
|
||||
[1518-11-03 00:24] falls asleep
|
||||
[1518-11-03 00:29] wakes up
|
||||
[1518-11-04 00:02] Guard #99 begins shift
|
||||
[1518-11-04 00:36] falls asleep
|
||||
[1518-11-04 00:46] wakes up
|
||||
[1518-11-05 00:03] Guard #99 begins shift
|
||||
[1518-11-05 00:45] falls asleep
|
||||
[1518-11-05 00:55] wakes up
|
||||
1
inputs/test_input5_1
Normal file
1
inputs/test_input5_1
Normal file
@ -0,0 +1 @@
|
||||
dabAcCaCBAcCcaDA
|
||||
6
inputs/test_input6_1
Normal file
6
inputs/test_input6_1
Normal file
@ -0,0 +1,6 @@
|
||||
1, 1
|
||||
1, 6
|
||||
8, 3
|
||||
3, 4
|
||||
5, 5
|
||||
8, 9
|
||||
41
main.py
Normal file
41
main.py
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tools.aoc
|
||||
import argparse
|
||||
import importlib
|
||||
import os
|
||||
|
||||
YEAR = 2021
|
||||
TIMEIT_NUMBER = 50
|
||||
|
||||
argument_parser = argparse.ArgumentParser()
|
||||
argument_parser.add_argument("-d", "--day", help="specify day to process; leave empty for ALL days", type=int)
|
||||
argument_parser.add_argument("-p", "--part", help="run only part x", choices=[1, 2], type=int)
|
||||
argument_parser.add_argument("--timeit", help="measure execution time", action="store_true", default=False)
|
||||
argument_parser.add_argument(
|
||||
"--timeit-number",
|
||||
help="build average time over this many executions",
|
||||
type=int,
|
||||
default=TIMEIT_NUMBER
|
||||
)
|
||||
argument_parser.add_argument("-v", "--verbose", help="show test case outputs", action="store_true", default=False)
|
||||
flags = argument_parser.parse_args()
|
||||
|
||||
import_day = ""
|
||||
if flags.day:
|
||||
import_day = "%02d" % flags.day
|
||||
|
||||
imported = []
|
||||
for _, _, files in os.walk(tools.aoc.BASE_PATH):
|
||||
for f in files:
|
||||
if f.startswith('day' + import_day) and f.endswith('.py'):
|
||||
lib_name = f[:-3]
|
||||
globals()[lib_name] = importlib.import_module(lib_name)
|
||||
imported.append(lib_name)
|
||||
|
||||
break
|
||||
|
||||
for lib in sorted(imported):
|
||||
day = int(lib[-2:])
|
||||
day_class = getattr(globals()[lib], "Day")(YEAR, day)
|
||||
day_class.run(flags.part if flags.part else 3, flags.verbose, flags.timeit, flags.timeit_number)
|
||||
24
skel_day.py
Normal file
24
skel_day.py
Normal file
@ -0,0 +1,24 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
(None, "input%DAY%"),
|
||||
],
|
||||
[
|
||||
(None, "input%DAY%"),
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
return ""
|
||||
|
||||
def part2(self) -> Any:
|
||||
return ""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(%YEAR%, %DAY%)
|
||||
day.run(verbose=True)
|
||||
51
start_day.py
Normal file
51
start_day.py
Normal file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
from argparse import ArgumentParser
|
||||
from datetime import datetime
|
||||
from os.path import exists
|
||||
from platform import system
|
||||
from subprocess import call
|
||||
from time import sleep
|
||||
import webbrowser
|
||||
|
||||
|
||||
YEAR = 2018
|
||||
CHARMS = {
|
||||
'Linux': '/usr/local/bin/charm',
|
||||
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
|
||||
}
|
||||
|
||||
arg_parser = ArgumentParser()
|
||||
arg_parser.add_argument("-d", "--day", help="start a specific day (default: today)", type=int)
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
DAY = args.day or datetime.now().day
|
||||
|
||||
if YEAR < 2015 or not 1 <= DAY <= 25:
|
||||
print("Invalid year or day for year: %d, day: %d" % (YEAR, DAY))
|
||||
exit()
|
||||
|
||||
day_file = "day%02d.py" % DAY
|
||||
if exists(day_file):
|
||||
print(day_file, "already exists. Use that one!")
|
||||
exit()
|
||||
|
||||
with open("skel_day.py", "r") as IN:
|
||||
with open(day_file, "w") as OUT:
|
||||
while in_line := IN.readline():
|
||||
OUT.write(in_line.replace("%YEAR%", str(YEAR)).replace("%DAY%", str(DAY)))
|
||||
|
||||
start = datetime(YEAR, 12, DAY, 6, 0, 0)
|
||||
now = datetime.now()
|
||||
if start > now:
|
||||
time_wait = start - now
|
||||
if time_wait.days > 0:
|
||||
print("Do you really want to wait %d days?" % time_wait.days)
|
||||
exit()
|
||||
|
||||
for x in range(time_wait.seconds, -1, -1):
|
||||
print("Day starts in %02ds.\r")
|
||||
sleep(1)
|
||||
|
||||
call([CHARMS[system()], day_file])
|
||||
webbrowser.open("https://adventofcode.com/%d/day/%d" % (YEAR, DAY))
|
||||
call(["git", "add", day_file])
|
||||
Loading…
Reference in New Issue
Block a user