Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@banyek
Last active December 2, 2017 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save banyek/891d557687e4b7b4f99d8bc21c406597 to your computer and use it in GitHub Desktop.
Save banyek/891d557687e4b7b4f99d8bc21c406597 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
def scalar(a, b):
acc = 0
for num in range(len(a)):
acc += a[num] * b[num]
return acc
def vectorial(a, b):
c = [None] * 3
c[0] = a[1] * b[2] - a[2] * b[1]
c[1] = a[2] * b[0] - a[0] * b[2]
c[2] = a[0] * b[1] - a[1] * b[0]
return c
def readvector():
read = raw_input()
tokens = read.split(",")
vector = []
for token in tokens:
vector.append(int(token))
return vector
print "Kerem az elso vektort"
v1 = readvector()
print "Kerem a masodik vektort"
v2 = readvector()
if len(v1) == len(v2):
print scalar(v1, v2)
if len(v1) == 3:
print vectorial(v1, v2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment