targetx = (175, 227) #(20, 30) targety = (-134, -79) #(-10, -5) trajectories = [] class probe: def __init__(self, velo): self.probe_position = (0, 0) self.velocity = velo self.initial_velo = velo def steppy(self): while self.probe_position[0] < targetx[1] and self.probe_position[1] > targety[0]: x, y = self.probe_position velox, veloy = self.velocity x += velox y += veloy if x >= targetx[0] and x <= targetx[1] and y <= targety[1] and y >= targety[0]: return self.initial_velo veloy -= 1 if velox != 0: if velox < 0: velox += 1 if velox > 0: velox -= 1 self.probe_position = (x, y) self.velocity = (velox, veloy) return None for yvelo in range(targety[0], 0 - targety[0]): for xvelo in range(1, targetx[1] + 1): prob = probe((xvelo, yvelo)) t = prob.steppy() if t is not None: trajectories.append(t) del prob print(len(trajectories))