Iterator Warm-up

easypy_functional

Four small iterator/collection utilities:

  • transpose(matrix) — transpose a rectangular matrix (rows ↔ columns).
  • uniq(sequence) — a generator yielding elements in order, dropping later duplicates (keep the first occurrence).
  • dict_merge(*dicts) — merge flat dicts; on a key collision the later dict wins.
  • product(lhs, rhs) — the scalar (dot) product of two equal-length int lists.

Your solution

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

transpose: zip(*matrix) pairs up the columns. uniq: yield items not seen before (it must be a generator).

Hint 2

dict_merge: update a result dict in order (later wins). product: sum of a*b over zip(lhs, rhs).