import re import os import sys import time import numpy as np import matplotlib.pyplot as plt # Constants RE_PATTERN = r"position=<\s*(\-*\d+),\s*(\-*\d+)> velocity=<([-*\s?]\d+), ([-?\s?]\d+)>" PATH = os.path.join(sys.path[0], '..', 'input') getX = lambda p : p.pos[0] getY = lambda p : p.pos[1] # MovingPoint (pos, velocity) class class MovingPoint(object): def __init__(self, input): match = re.search(RE_PATTERN, input) self.pos = [int(match.group(1)), int(match.group(2))] self.vel = [int(match.group(3)), int(match.group(4))] def simulate(self, t=1): self.pos[0] += self.vel[0] * t self.pos[1] += self.vel[1] * t def __repr__(self): return f"