Advertisement
cd62131

cyclic output

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