Skip to content

Commit 6719773

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

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2025/day04/solutions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
6+
7+
octdir = {1, 1j, -1, -1j, 1 + 1j, 1 - 1j, -1 + 1j, -1 - 1j}
8+
9+
removed = []
10+
while to_remove := {x for x in paper if len({x + d for d in octdir} & paper) < 4}:
11+
removed.append(len(to_remove))
12+
paper -= to_remove
13+
14+
# Part 1
15+
print(removed[0])
16+
17+
# Part 2
18+
print(sum(removed))

0 commit comments

Comments
 (0)