Premium problem160. Build a Broadcast View With a Zero Stride

Hard Locked

Given a 1-D array r of length m and integer n, build the (n, m) tiled view and return (view_as_lists, view.strides, view.nbytes, r.nbytes):

  • use as_strided
  • give the new axis a stride of 0

Input

r = [0 1 2]
n = 4

Output

([[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]], (0, 8), 96, 24)

Premium problem

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

Implement solve(...)