Home > AI > Language > Python >

(interview) Acquiring Coordinates


Given an array and a step shape, return a list of coordinates based on each step.

```py
import itertools
import numpy as np

def coordinates_from_steps(a, s, dtype=int):
    pass

print(coordinates_from_steps(np.array([[1,2],[3,4]]), (1,1)))
# [[0 0]
#  [0 1]
#  [1 0]
#  [1 1]]

print(coordinates_from_steps(np.array([[1,2],[3,4]]), (1,2)))
# [[0 0]
#  [1 0]]
```

Leave a Reply