Unit Vectors
Each row of vectors is a vector (a list of numbers). Return a 2-D array in which every row has been divided by its own length (the square root of the sum of its squares), so each row of the result has length 1. No row is all zeros.
Example 1
vectors [[3,4],[0,2]]
returns [[0.6,0.8],[0.0,1.0]]
The lengths are 5 and 2, giving [0.6, 0.8] and [0, 1].
Constraints
1 <= rows, columns <= 10- No row is made only of zeros
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.