Skip to content

Commit 5c34811

Browse files
authored
Merge pull request #244 from Gattocrucco/alt-sol-87
Alternative solution to exercise 87
2 parents 2db57d0 + fc72693 commit 5c34811

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

source/exercises100.ktx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,11 +1337,8 @@ k = 4
13371337
windows = np.lib.stride_tricks.sliding_window_view(Z, (k, k))
13381338
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
13391339

1340-
# Author: Jeff Luo (@Jeff1999)
1341-
1342-
Z = np.ones((16, 16))
1343-
k = 4
1344-
print(sliding_window_view(Z, window_shape=(k, k))[::k, ::k].sum(axis=(-2, -1)))
1340+
# alternative solution (by @Gattocrucco)
1341+
S = Z.reshape(4, 4, 4, 4).sum((1, 3))
13451342

13461343
< q88
13471344
How to implement the Game of Life using numpy arrays? (★★★)

0 commit comments

Comments
 (0)