Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0 0 0 0
- 0 0 0 1
- 0 0 0 1
- 0 0 0 1
- 0 1 1 1
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
- import numpy as np
- In [86]: l
- Out[86]: [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]
- In [87]: a = np.array(l)
- In [70]: a
- Out[70]:
- array([[0, 0, 0, 0],
- [0, 0, 0, 1],
- [0, 0, 0, 1],
- [0, 0, 0, 1]], dtype=int64)
- In [71]: np.rot90(a)
- Out[71]:
- array([[0, 1, 1, 1],
- [0, 0, 0, 0],
- [0, 0, 0, 0],
- [0, 0, 0, 0]], dtype=int64)
- In [72]: np.rot90(a, k=2)
- Out[72]:
- array([[1, 0, 0, 0],
- [1, 0, 0, 0],
- [1, 0, 0, 0],
- [0, 0, 0, 0]], dtype=int64)
- In [107]: np.rot90(a).tolist()
- Out[107]: [[0, 1, 1, 1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Add Comment
Please, Sign In to add comment