Skip to content

Commit f3a3e1f

Browse files
committed
More numpy for speed
1 parent 4a479c1 commit f3a3e1f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

2024/src/aoc/days/day25.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ def run_both(cls, input: str) -> tuple[int, None]:
2020
else:
2121
keys.append(heights)
2222

23-
fitting = 0
23+
locks = numpy.stack(locks, axis=0)
2424

25-
for key in keys:
26-
for lock in locks:
27-
if numpy.all((key + lock) <= 7):
28-
fitting += 1
25+
fitting = sum(
26+
numpy.count_nonzero(numpy.all((key + locks) <= 7, axis=1)) for key in keys
27+
)
2928

3029
return fitting, None

0 commit comments

Comments
 (0)