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

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()))