All problems
Infinity Vector Norm
Problem
Compute the infinity norm of a vector v: the maximum absolute component.
||v||_inf = max(|v[i]|). Return 0.0 for an empty vector.
Hint
Take the max of the absolute values.
Test cases
case 1
in: [[3,-4,2]]
expected: 4
case 2
in: [[0,0,0]]
expected: 0
case 3
in: [[-7]]
expected: 7
case 4
in: [[1.5,-9.25,3]]
expected: 9.25
Starter codePython
def inf_norm(v):
# Your code here
pass4 test cases · run your code against them in the editor