We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0f700d1 commit a17e264Copy full SHA for a17e264
1 file changed
math_library.py
@@ -1,4 +1,12 @@
1
def scalar_product(vector1, vector2):
2
if len(vector1) != len(vector2):
3
raise ValueError("Vectors must be of the same length")
4
- return sum(x * y for x, y in zip(vector1, vector2))
+ return sum(x * y for x, y in zip(vector1, vector2))
5
+def vector_product(vector1, vector2):
6
+ if len(vector1) != 3 or len(vector2) != 3:
7
+ raise ValueError("Both vectors must be of length 3")
8
+ return [
9
+ vector1[1] * vector2[2] - vector1[2] * vector2[1],
10
+ vector1[2] * vector2[0] - vector1[0] * vector2[2],
11
+ vector1[0] * vector2[1] - vector1[1] * vector2[0]
12
+ ]
0 commit comments