add: day07: part1
This commit is contained in:
27
2025/day07/part1.py
Normal file
27
2025/day07/part1.py
Normal file
@ -0,0 +1,27 @@
|
||||
text: str
|
||||
|
||||
with open("input.txt") as f:
|
||||
text = f.read()
|
||||
|
||||
total: int = 0
|
||||
|
||||
lines = [[c for c in line] for line in text.splitlines()]
|
||||
|
||||
roots: set[int] = set()
|
||||
roots.add(len(lines[0]) // 2)
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
for j, c in enumerate(line):
|
||||
if (c == '^' and j in roots):
|
||||
roots.remove(j)
|
||||
roots.add(j - 1)
|
||||
roots.add(j + 1)
|
||||
total += 1
|
||||
# debug print()
|
||||
for root in roots:
|
||||
line[root] = "|"
|
||||
|
||||
for line in lines:
|
||||
print("".join(line))
|
||||
|
||||
print(total)
|
||||
Reference in New Issue
Block a user