advent_of_code/2025/7/7.py
kleph 4174f627fc
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2025 - Day 7 part 1
2025-12-08 15:05:39 +01:00

35 lines
No EOL
788 B
Python

#!/usr/bin/env python
# 2025 - Advent Of Code 7
# file = 'input_example.txt'
file = 'input.txt'
# pylint: disable=consider-using-with
grid = [line.strip('\n') for line in open(file, encoding="utf-8")]
MAX_X = len(grid[0])
MAX_Y = len(grid)
for s in range(0, len(grid[0])):
if grid[0][s] == 'S':
start_pos = (s, 0)
break
print(f'{start_pos=}')
beams = [start_pos]
split = 0
for liney in range(1, MAX_Y-1):
new_beams = []
for b in beams:
x = b[0]
y = b[1]
if grid[y+1][x] == '^':
new_beams.append((x-1, y+1))
new_beams.append((x+1, y + 1))
split += 1
else:
new_beams.append((x, y + 1))
print(f'end {liney}: {new_beams}')
beams = list(set(new_beams))
print(f'{split=}')