Premium problem62. Sum via Iterator

Medium Locked

Given arrays A of shape (3, 1) and B of shape (1, 3), return their broadcasted sum as a (3, 3) array:

  • iterate over matching elements one at a time
  • do not rely on a single vectorized + expression

Input

A =
[[0]
 [1]
 [2]]
B = [[0 1 2]]

Output

[[0 1 2]
 [1 2 3]
 [2 3 4]]

Only the returned value is graded, so a different approach will still pass. The constraint is the point of the exercise, not a rule the grader enforces.

Premium problem

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

Implement solve(...)