Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-110

Span Membership 2D

Problem

Return True if vector w lies in the span of vector v in R^2, meaning w is a scalar multiple of v.

Handle the zero vector: if v is [0, 0], the only member of its span is w = [0, 0].

Hint

Two 2D vectors are parallel exactly when their cross product is zero.

Test cases

case 1
in: [[1,2],[2,4]]
expected: true
case 2
in: [[1,2],[2,3]]
expected: false
case 3
in: [[0,0],[0,0]]
expected: true
case 4
in: [[0,0],[1,1]]
expected: false
Starter codePython
def is_scalar_multiple_2d(v, w):
    # Your code here
    pass

4 test cases · run your code against them in the editor