Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-056

Vector Linear Interpolation

Problem

Linearly interpolate between vectors a and b with parameter t:

lerp(a, b, t) = a + t * (b - a)

Return a list of floats; t = 0 gives a and t = 1 gives b.

Hint

Interpolate each component independently.

Test cases

case 1
in: [[0,0],[10,20],0.5]
expected: [5,10]
case 2
in: [[1,1],[3,5],0.25]
expected: [1.5,2]
case 3
in: [[2,4],[2,4],0.7]
expected: [2,4]
case 4
in: [[0,0],[4,8],0]
expected: [0,0]
Starter codePython
def lerp_vectors(a, b, t):
    # Your code here
    pass

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