Skip to content

Commit 65baa5c

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

2025/day04/solutions.py

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

0 commit comments

Comments
 (0)