This commit is contained in:
Aéna Aria 2025-12-07 16:19:58 +01:00
parent 41faa54e45
commit bdeef8224d
5 changed files with 469 additions and 0 deletions

22
day7/1.py Normal file
View file

@ -0,0 +1,22 @@
with open(r'day7/input.txt', 'r') as input:
lines = input.read().split('\n')[:-1]
active = set([lines[0].index('S')])
split_cnt = 0
for line in lines[1:]:
active_buf = set()
for i in active:
if line[i] == '^':
if i > 0:
active_buf.add(i-1)
if i < len(line) -1:
active_buf.add(i+1)
split_cnt+=1
else:
active_buf.add(i)
active = active_buf
print(split_cnt)

18
day7/2.py Normal file
View file

@ -0,0 +1,18 @@
with open(r'day7/input.txt', 'r') as input:
lines = input.read().split('\n')[:-1]
active = {lines[0].index('S'):1}
for line in lines[1:]:
active_buf = {}
for i in active:
if line[i] == '^':
if i > 0:
active_buf[i-1] = active[i] if i-1 not in active_buf.keys() else active_buf[i-1] + active[i]
if i < len(line) -1:
active_buf[i+1] = active[i] if i+1 not in active_buf.keys() else active_buf[i+1] + active[i]
else:
active_buf[i] = active[i] if i not in active_buf.keys() else active_buf[i] + active[i]
active = active_buf
print(sum(active.values()))

142
day7/input.txt Normal file
View file

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