Guest User

Untitled

a guest
Mar 18th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. 0 0 0 0
  2. 0 0 0 1
  3. 0 0 0 1
  4. 0 0 0 1
  5.  
  6. 0 1 1 1
  7. 0 0 0 0
  8. 0 0 0 0
  9. 0 0 0 0
  10.  
  11. import numpy as np
  12.  
  13. In [86]: l
  14. Out[86]: [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]]
  15.  
  16. In [87]: a = np.array(l)
  17.  
  18. In [70]: a
  19. Out[70]:
  20. array([[0, 0, 0, 0],
  21. [0, 0, 0, 1],
  22. [0, 0, 0, 1],
  23. [0, 0, 0, 1]], dtype=int64)
  24.  
  25. In [71]: np.rot90(a)
  26. Out[71]:
  27. array([[0, 1, 1, 1],
  28. [0, 0, 0, 0],
  29. [0, 0, 0, 0],
  30. [0, 0, 0, 0]], dtype=int64)
  31.  
  32. In [72]: np.rot90(a, k=2)
  33. Out[72]:
  34. array([[1, 0, 0, 0],
  35. [1, 0, 0, 0],
  36. [1, 0, 0, 0],
  37. [0, 0, 0, 0]], dtype=int64)
  38.  
  39. In [107]: np.rot90(a).tolist()
  40. 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