import math class Vector: def __init__(self, coords): self.coords = coords def __repr__(self): return self.coords.__repr__() def __add__(self, other): return Vector([a+b for a,b in zip(self.coords, other.coords)]) def __sub__(self, other): return Vector([a-b for a,b in zip(self.coords, other.coords)]) def __mul__(self, scale): return Vector([scale*a for a in self.coords]) def __div__(self, scale): return Vector([a/scale for a in self.coords]) def __rmul__(self, scale): return self*scale def dot(self, other): return sum([a*b for a,b in zip(self.coords, other.coords)]) def mag(self): return math.sqrt(self.dot(self))