This commit is contained in:
Stefan Harmuth 2025-12-07 07:04:25 +01:00
parent 46f9d7067e
commit 553016c043
3 changed files with 208 additions and 0 deletions

50
day07.py Normal file
View File

@ -0,0 +1,50 @@
from tools.aoc import AOCDay
from tools.coordinate import Coordinate
from tools.grid import Grid
from typing import Any
class Day(AOCDay):
inputs = [
[
(21, "input7_test"),
(1703, "input7"),
],
[
(40, "input7_test"),
(171692855075500, "input7"),
]
]
def get_timeline_count(self, start: Coordinate, grid: Grid) -> int:
if not grid.isWithinBoundaries(start):
return 1
while not grid.get(start) and grid.isWithinBoundaries(start):
start += (0, 1)
if not grid.isWithinBoundaries(start):
return 1
else:
if start in self.DP:
return self.DP[start]
self.SEEN.add(start)
ans = self.get_timeline_count(start + (-1, 0), grid) + self.get_timeline_count(start + (1, 0), grid)
self.DP[start] = ans
return ans
def part1(self) -> Any:
grid = Grid.from_data(self.getInput(), translate={'.': False, '^': True})
self.get_timeline_count(list(grid.find('S'))[0], grid)
return len(self.SEEN)
def part2(self) -> Any:
grid = Grid.from_data(self.getInput(), translate={'.': False, '^': True})
return self.get_timeline_count(list(grid.find('S'))[0], grid)
if __name__ == '__main__':
day = Day(2025, 7)
day.run(verbose=True)

142
inputs/input7 Normal file
View File

@ -0,0 +1,142 @@
......................................................................S......................................................................
.............................................................................................................................................
......................................................................^......................................................................
.............................................................................................................................................
.....................................................................^.^.....................................................................
.............................................................................................................................................
....................................................................^.^.^....................................................................
.............................................................................................................................................
...................................................................^.^.^.^...................................................................
.............................................................................................................................................
..................................................................^.^.^...^..................................................................
.............................................................................................................................................
.................................................................^...^.^.^.^.................................................................
.............................................................................................................................................
................................................................^.^.^...^.^.^................................................................
.............................................................................................................................................
...............................................................^.^...........^...............................................................
.............................................................................................................................................
..............................................................^.^.^.^.^.^.^...^..............................................................
.............................................................................................................................................
.............................................................^...^.^.^.^.^.^.^.^.............................................................
.............................................................................................................................................
............................................................^.^.^...^.^...^.^...^............................................................
.............................................................................................................................................
...........................................................^.^.^.^.^...^.^...^...^...........................................................
.............................................................................................................................................
..........................................................^...^.^.^.^.^...^.^.....^..........................................................
.............................................................................................................................................
.........................................................^...^.^.^...^...^.^.^.^.^.^.........................................................
.............................................................................................................................................
........................................................^.^.^...^.....^.^.^.^.^.....^........................................................
.............................................................................................................................................
.......................................................^.^.^.^.^.^.^.......^.^.^.....^.......................................................
.............................................................................................................................................
......................................................^...^.^...^...^.^.^.^.^.^.^...^.^......................................................
.............................................................................................................................................
.....................................................^.^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.....................................................
.............................................................................................................................................
....................................................^.^.^...^.^.....^.^.^.^.^.^.^.^...^.^....................................................
.............................................................................................................................................
...................................................^.^.^.^.^.^...^.^...^.^.^...^...^...^.^...................................................
.............................................................................................................................................
..................................................^.....^...^.^...^.^.........^.^.^.....^.^..................................................
.............................................................................................................................................
.................................................^.......^.^.^...^.^.^...^.^...^.^.^...^.^.^.................................................
.............................................................................................................................................
................................................^.^.^.^.^.^.^.^.....^...^.^...^.^.....^.^.^.^................................................
.............................................................................................................................................
...............................................^.....^.^.^...^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^...............................................
.............................................................................................................................................
..............................................^...^...^...^...^.....^.^.^.....^.^...^.^.^.^.^.^..............................................
.............................................................................................................................................
.............................................^.^.^.^.^.^...^...^.^.^.....^.^.^.^.^.^.^...^.^...^.............................................
.............................................................................................................................................
............................................^.^.^.^.^.^.....^.^.^...^.^.....^.^...^.^.^.....^.^.^............................................
.............................................................................................................................................
...........................................^.^...^.^.^...^.^.^.^.^.^.^.^...^.^...^.^.^.^.....^.^.^...........................................
.............................................................................................................................................
..........................................^.^.^.^.^.^.^.^...^.^.^.^...^.^.^...^.^.^.^.^.^.........^..........................................
.............................................................................................................................................
.........................................^.^.^.^.^.^.^...^.^.....^...^.^...^.^...^.^.^.^.^.^.^.^.^.^.........................................
.............................................................................................................................................
........................................^...^.......^.....^.^.^...^.^.^.^...^.^.^.^.^...^.^.^.....^.^........................................
.............................................................................................................................................
.......................................^.^.^...^.^...^.^.^.^.^.^.^.^.^.^.....^...^.^.^.^.^.^.^.^...^.^.......................................
.............................................................................................................................................
......................................^...^.^.^...^.^.^.^...^...^.^...^.^.^.^.^.^...^.^.....^.^.^.^.^.^......................................
.............................................................................................................................................
.....................................^.^.^.^.^...^...^.^...^...^.^.^.^.^.^.....^...^...^...^.^.^...^.^.^.....................................
.............................................................................................................................................
....................................^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^...^...^.....^....................................
.............................................................................................................................................
...................................^.^...^.^...^...^.^.....^.....^.....^.^.^.^.^.^.^.....^.^.^.^...^...^.^...................................
.............................................................................................................................................
..................................^.^...^.^.^...^.......^.^...^.^.^.^.^...^.^.^...^.^.^.....^.^.^.^.^.^.^.^..................................
.............................................................................................................................................
.................................^...^.^.....^.^.^.^.^.....^.^...^.^.^...^...^.^.^.^.^.^.^.^...^.^...^.^...^.................................
.............................................................................................................................................
................................^.^.^.^.^...^.^...^.^.^.^.^.^.^.......^.....^...^.^.^.^.^.^.^.^.^.....^.^.^.^................................
.............................................................................................................................................
...............................^...^.^...^...^...^.^.^.^.....^.....^.^.^.^.....^...^.^...^.^...^.^.^.^.^.^...^...............................
.............................................................................................................................................
..............................^.^.^.^...........^.^.^.^.^.^.^.^.^.^.^.^.^...^...^.^.^...^.^.^.^.^.^...^.^.^.^.^..............................
.............................................................................................................................................
.............................^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^...^...^...^.^.....^...^.^.^.^...^.^.^.............................
.............................................................................................................................................
............................^.^...^.^.^.^.^.^.^.....^.........^.^.^.^.^...^.^...^.^...^.^.^.^.^.^...^.^.^...^.^.^............................
.............................................................................................................................................
...........................^.^...^.^.^.^.^.....^.........^.^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^...^.^.^.^...........................
.............................................................................................................................................
..........................^.^...^.^...^...^.^.^.^...^.^...^.^...^.^.^.^.^.^.......^.^.^.^.^.^.^.^.^.^.^.....^...^.^..........................
.............................................................................................................................................
.........................^.....^.^.^.^.....^.^.^...^...^...^.^...^.^...^.^...^.^.....^.^.^...^.^.^.^.^...^.^.^.^...^.........................
.............................................................................................................................................
........................^.^.^...^.^.^...^.^...^.^...^.^.^.....^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.....^.^.^.^.^...^...^.^........................
.............................................................................................................................................
.......................^.^...^.^.^.^.^.^.^.^.......^...^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.^...^.^.^...^.^.^.^...^.^.^.......................
.............................................................................................................................................
......................^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^...^.^.^.^.....^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.......^.^.^.^.^......................
.............................................................................................................................................
.....................^.^...^.^.^.^.^.....^.^.^.^.^...^.^.^.^.^.^...^.....^.^.^.^.^.^...^.^.....^...^.^.^.....^.^...^.^.^.....................
.............................................................................................................................................
....................^.^...^...^...^.....^.^.^.^.^...^...^.^.^.^.....^...^.^.^.^.^.^.^.^...^.^.^.^...^.^...^.....^.^.^.^.^....................
.............................................................................................................................................
...................^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^...^...^.^...^...^.^.^.^.^.^...^.....^.^...^.^.^.^.^.^.^.^.......^...................
.............................................................................................................................................
..................^.^.^.^...^.^.^.^.....^.^.^...^.^.^.^...^...^.^.^.^.^...^.^.^.....^.^.^.^.^.^...^...^.^.......^.^.^...^.^..................
.............................................................................................................................................
.................^.^.^.^.^.....^.^.^.^.^.^...^.^.^.^.^.^.^...^.......^.^.^.^.^...^.^.^.^...^.....^.^.^.^.^...^.^.^.^.....^.^.................
.............................................................................................................................................
................^.^.^...^.^.^.^.^.^.^.^.^.^.^.^...^.^...^.....^.^...^.^.^.^.........^.^.^...^.....^.^.^.....^.^...^.^.......^................
.............................................................................................................................................
...............^.^.^.^.^.^...^.^.^.....^.^.^...^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.......^...^...^...^.^...^.^.^...^.^.^.^.^.^.^...............
.............................................................................................................................................
..............^.^.^.^.......^...^...^.^.^.^...^...^.^.^...^.^.^.......^.^.^...^...^.^.^...^...^.^.^.^.^...^.^.^.^.^.^...^...^.^..............
.............................................................................................................................................
.............^.^...^.^.^...^.^.^.^.^...^.^.^.^.....^.....^.^...^...^.^.^.^.^.^.^.^.^.^...^.....^.^.^.^.^.^.^.^...^.^...^...^...^.............
.............................................................................................................................................
............^.^.^...^.^.....^.^.^.....^...^.^...^...^.^.^.^...^.^...^.....^.......^.^.^.......^.^.^.^.^.^...^.^.....^.^.^.^.^.^.^............
.............................................................................................................................................
...........^.^.^...^.^.^.....^.^.^...^.^.^.....^.^...^...^.^.....^.^.^.^.^.^.^.^.....^.^.^.^.^...^.^...^.^.^.^.^.^.^.^...^.......^...........
.............................................................................................................................................
..........^.^.....^...^.^.^.......^.^.^.^.^.^.^.....^.^.^.^.^.^...^.^.^.^...^.^...^.^.....^.^.^.^.^...^...^.....^...^.^.^.^.^.^.^.^..........
.............................................................................................................................................
.........^.^.......^.^.^...^.^...^.^...^.^.^.^.^.^.^.^.^.....^...^.^.^.^...^.....^...^.^.^...^.^.^.^.^.^.^.^.^...^.^.^...^.^...^.^.^.........
.............................................................................................................................................
........^.^.^.^.^.......^.....^.^.^.^.^.^.....^.^.^.^.^...^.^.^.^.^...^.^...^.^...^.^.^...^.^.^.^.^.^.^.....^.^.^.^...^...^.....^.^.^........
.............................................................................................................................................
.......^...^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.....^.^.^.^.^...^.^...^.^.^.^.^...^.^.^.....^.^.^.^...^.^.^.....^...^.^...^.^...^.^.......
.............................................................................................................................................
......^.^.^.^.^.^.^.....^...^.^.^.....^...^...^...^.^.^.^.^.^.^.^.^.^.^.^.^.^...^.^.^.^.^.....^.....^.^.^.^.^...^.^.^.^.^...^.^...^.^.^......
.............................................................................................................................................
.....^.^.^.......^.^.^.....^.....^.^.^.^.....^.......^.^.^.^...^.^.^.^.^.^...^.^.^.^.^.....^.^...^.^...^.^.^.^.....^.^.^.....^...^...^.^.....
.............................................................................................................................................
....^...^...^.^...^...^.^.^.^.....^.^...^.^.^.^.^.^.......^.^...^.^...^.....^.^.^.^.^.^.^.^.^.^...^.^.^.....^...^.^...^.^.^.^...^...^...^....
.............................................................................................................................................
...^.^.^.^.^.^...^.^.^...^.^.^.......^.^.^.^.^.^.^.^.^...^.^.^.^.^.^.^.^.^.^.^.....^...^.^.^.^.^.^.^.............^.^.^...^...^.^.......^.^...
.............................................................................................................................................
..^...^.^.^.^.^.^.^.^.^.......^.^.^.^...^...^.^.^.^.^.^.^.^.^.^.....^.^.^...^.....^.^.^.^.^.^.^.......^.^...^.^.^.^.^...^...^.^.^.......^.^..
.............................................................................................................................................
.^.^...^.^.^.^.^.^...^.^.^.^.^.^.^.^.....^...^.^.^...^.^.^.^.^...^.^.^.^...^.^.^.^.^.^.^...^.^.^...^.....^...^.......^.^.^...^.^...^...^.^.^.
.............................................................................................................................................

16
inputs/input7_test Normal file
View File

@ -0,0 +1,16 @@
.......S.......
...............
.......^.......
...............
......^.^......
...............
.....^.^.^.....
...............
....^.^...^....
...............
...^.^...^.^...
...............
..^...^.....^..
...............
.^.^.^.^.^...^.
...............