Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- array = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15],
- [16, 17, 18, 19, 20]])
- Y, X = array.shape
- D = np.array([(1, 0, X - 1), (0, 1, Y - 1), (-1, 0, X - 1), (0, -1, Y - 1)])
- x = y = 0
- for dx, dy, n in D:
- for _ in range(n):
- print(array[y][x])
- x += dx
- y += dy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement