Split into Equal Parts

easynumpy_combine

Implement split_equal(x, n).

Given a 1D array x whose length is divisible by n, split it into n equal-length contiguous parts and return them as a list of n arrays. For example split_equal([1, 2, 3, 4, 5, 6], 3)[[1, 2], [3, 4], [5, 6]]. No for/while loops.

Constraints
  • no for/while loops

Your solution

Edit split_equal and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

np.split(x, n) divides x into n equal-length sub-arrays (it returns a list).