day 7 part 1

This commit is contained in:
magical 2025-12-07 08:11:12 +00:00
parent 1a4f2da0ce
commit 84fe8156a0
3 changed files with 183 additions and 0 deletions

142
day07/input Normal file
View File

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

16
day07/sample Normal file
View File

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

25
day07/sol.py Normal file
View File

@ -0,0 +1,25 @@
def solve(input):
splits = 0
pos = []
for row in open(input):
row = row.strip()
next = []
for i in pos:
if row[i] == '.':
next.append(i)
elif row[i] == '^':
if i-1 >= 0:
next.append(i-1)
if i+1 < len(row):
next.append(i+1)
splits += 1
start = row.find('S')
if start >= 0:
next.append(start)
pos = sorted(set(next))
print(splits)
solve("sample")
solve("input")