further simplification to the alt solution of 87
The initial formulation contained a redundant `swapaxes`.
This commit is contained in:
@@ -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? (★★★)
|
||||
|
||||
Reference in New Issue
Block a user