Premium problem154. Find the Unit-Stride Axis

Medium Locked

Return the index of the axis of A with the smallest absolute stride:

  • that is the axis a loop should iterate innermost for cache-friendly access
  • return -1 if the array has any zero-stride axis

Input

[[[0. 0. 0. 0.]
  [0. 0. 0. 0.]
  [0. 0. 0. 0.]]

 [[0. 0. 0. 0.]
  [0. 0. 0. 0.]
  [0. 0. 0. 0.]]]

Output

2

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)