Skip to content

Commit 776492d

Browse files
committed
Add solution to 2025-12-04
1 parent 03ab000 commit 776492d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2025/day04/solutions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
with open("input") as f:
2+
ls = f.read().strip().split("\n")
3+
4+
paper = {i + 1j * j for i, l in enumerate(ls) for j, c in enumerate(l) if c == "@"}
5+
octdir = {1, 1j, -1, -1j, 1 + 1j, 1 - 1j, -1 + 1j, -1 - 1j}
6+
removed = []
7+
while to_remove := {z for z in paper if len({z + dz for dz in octdir} & paper) < 4}:
8+
removed.append(len(to_remove))
9+
paper -= to_remove
10+
11+
# Part 1
12+
print(removed[0])
13+
14+
# Part 2
15+
print(sum(removed))

0 commit comments

Comments
 (0)