Rows of Width
Cut arr into rows of w numbers each and return the resulting 2-D array (fill row 0 first, then row 1, and so on). len(arr) is always a multiple of w.
Example 1
arr [1,2,3,4,5,6]
w 3
returns [[1,2,3],[4,5,6]]
The rows are [1, 2, 3] and [4, 5, 6].
Constraints
1 <= len(arr) <= 60len(arr)is a multiple ofw
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Runner-Up per RowEasy
- Running Total per ColumnEasy
- Scale to Zero OneEasy
- Second LargestEasy
- Smallest PositiveEasy
- Softmax WeightsEasy
- Sort Each RowEasy
- Strong RowsEasy