All problems
Vandermonde Determinant
Problem
Compute the determinant of the Vandermonde matrix built from the values x without forming the matrix:
det = product over i < j of (x[j] - x[i])
Repeated values make the determinant 0.
Hint
Each pair of values contributes a difference factor.
Test cases
case 1
in: [[1,2,3]]
expected: 2
case 2
in: [[0,1]]
expected: 1
case 3
in: [[2,2,3]]
expected: 0
case 4
in: [[1,2,3,4]]
expected: 12
Starter codePython
def vandermonde_det(x):
# Your code here
pass4 test cases · run your code against them in the editor