further simplification to the alt solution of 87
The initial formulation contained a redundant `swapaxes`.
This commit is contained in:
@@ -1087,7 +1087,7 @@ windows = np.lib.stride_tricks.sliding_window_view(Z, (k, k))
|
|||||||
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
||||||
|
|
||||||
# alternative solution (by @Gattocrucco)
|
# 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))
|
||||||
```
|
```
|
||||||
#### 88. How to implement the Game of Life using numpy arrays? (★★★)
|
#### 88. How to implement the Game of Life using numpy arrays? (★★★)
|
||||||
`No hints provided...`
|
`No hints provided...`
|
||||||
|
|||||||
@@ -1087,7 +1087,7 @@ windows = np.lib.stride_tricks.sliding_window_view(Z, (k, k))
|
|||||||
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
||||||
|
|
||||||
# alternative solution (by @Gattocrucco)
|
# 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))
|
||||||
```
|
```
|
||||||
#### 88. How to implement the Game of Life using numpy arrays? (★★★)
|
#### 88. How to implement the Game of Life using numpy arrays? (★★★)
|
||||||
|
|
||||||
|
|||||||
@@ -1334,7 +1334,7 @@ windows = np.lib.stride_tricks.sliding_window_view(Z, (k, k))
|
|||||||
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
S = windows[::k, ::k, ...].sum(axis=(-2, -1))
|
||||||
|
|
||||||
# alternative solution (by @Gattocrucco)
|
# 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
|
< q88
|
||||||
How to implement the Game of Life using numpy arrays? (★★★)
|
How to implement the Game of Life using numpy arrays? (★★★)
|
||||||
|
|||||||
Reference in New Issue
Block a user