Flatten an Array

easynumpy_basics

Implement flatten(X).

Given an array X of any shape, return a 1D array containing all of its elements in row-major (C) order — the first row, then the second, and so on. No for/while loops.

Constraints
  • no for/while loops

Your solution

Edit flatten 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

x.ravel() (or x.flatten(), or x.reshape(-1)) returns all elements in row-major order.