Skip to content

Commit 1f987b4

Browse files
committed
2024 d25: Encode (r, c) as r * h + c
1 parent ad9ad57 commit 1f987b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

2024/solutions/day25.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55

66
def grid_to_set(grid):
7+
h = len(grid)
8+
79
points = set()
810
for r, row in enumerate(grid):
9-
points.update((r, c) for c, char in enumerate(row) if char == '#')
11+
points.update(r * h + c for c, char in enumerate(row) if char == '#')
1012

1113
return points, row == '#####'
1214

0 commit comments

Comments
 (0)