further simplification to the alt solution of 87

The initial formulation contained a redundant `swapaxes`.
This commit is contained in:
Gattocrucco
2025-08-26 00:16:34 +02:00
parent 59a403da66
commit 301e0eb61e
3 changed files with 3 additions and 3 deletions

View File

@@ -1334,7 +1334,7 @@ windows = np.lib.stride_tricks.sliding_window_view(Z, (k, k))
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
# alternative solution (by @Gattocrucco)
S = Z.reshape(4, 4, 4, 4).swapaxes(1, 2).sum((2, 3))
S = Z.reshape(4, 4, 4, 4).sum((1, 3))
< q88
How to implement the Game of Life using numpy arrays? (★★★)