day15
This commit is contained in:
parent
6633a11e9d
commit
6e40549618
42
day15.py
Normal file
42
day15.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
from tools.aoc import AOCDay
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
def solve(disks: list[tuple[int, int, int]]) -> int:
|
||||||
|
time = 0
|
||||||
|
while not all((time + disk_id + cur_pos) % num_pos == 0 for disk_id, num_pos, cur_pos in disks):
|
||||||
|
time += 1
|
||||||
|
|
||||||
|
return time
|
||||||
|
|
||||||
|
|
||||||
|
class Day(AOCDay):
|
||||||
|
inputs = [
|
||||||
|
[
|
||||||
|
(5, "input15_test"),
|
||||||
|
(376777, "input15"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
(3903937, "input15"),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def parse_input(self) -> list[tuple[int, int, int]]:
|
||||||
|
disks = []
|
||||||
|
for disk in self.getIntsFromInput():
|
||||||
|
disks.append((disk[0], disk[1], disk[3]))
|
||||||
|
|
||||||
|
return disks
|
||||||
|
|
||||||
|
def part1(self) -> Any:
|
||||||
|
disks = self.parse_input()
|
||||||
|
return solve(disks)
|
||||||
|
|
||||||
|
def part2(self) -> Any:
|
||||||
|
disks = self.parse_input()
|
||||||
|
disks = disks + [(len(disks) + 1, 11, 0)]
|
||||||
|
return solve(disks)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
day = Day(2016, 15)
|
||||||
|
day.run(verbose=True)
|
||||||
6
inputs/input15
Normal file
6
inputs/input15
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Disc #1 has 13 positions; at time=0, it is at position 1.
|
||||||
|
Disc #2 has 19 positions; at time=0, it is at position 10.
|
||||||
|
Disc #3 has 3 positions; at time=0, it is at position 2.
|
||||||
|
Disc #4 has 7 positions; at time=0, it is at position 1.
|
||||||
|
Disc #5 has 5 positions; at time=0, it is at position 3.
|
||||||
|
Disc #6 has 17 positions; at time=0, it is at position 5.
|
||||||
2
inputs/input15_test
Normal file
2
inputs/input15_test
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Disc #1 has 5 positions; at time=0, it is at position 4.
|
||||||
|
Disc #2 has 2 positions; at time=0, it is at position 1.
|
||||||
2
start_day.py
Normal file → Executable file
2
start_day.py
Normal file → Executable file
@ -11,7 +11,7 @@ import webbrowser
|
|||||||
|
|
||||||
YEAR = 2016
|
YEAR = 2016
|
||||||
CHARMS = {
|
CHARMS = {
|
||||||
'Linux': '/usr/local/bin/charm',
|
'Linux': '~/.local/share/JetBrains/Toolbox/scripts/pycharm',
|
||||||
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
|
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user