| 17 | |
| 18 | |
| 19 | class Dot: |
| 20 | def __init__(self, r: int = 0, c: int = 0, t: int = 1) -> None: |
| 21 | # Initialize current point and tail to initial point. |
| 22 | self.row = np.ones(t, dtype="int32") * r |
| 23 | self.col = np.ones(t, dtype="int32") * c |
| 24 | |
| 25 | def move(self, r: int, c: int): |
| 26 | """ |
| 27 | Cycle path history and set new current coordinates. |
| 28 | |
| 29 | :param r: row |
| 30 | :param c: column |
| 31 | """ |
| 32 | |
| 33 | # Cycle the path history. |
| 34 | for t in reversed(range(1, len(self.row))): |
| 35 | self.row[t] = self.row[t - 1] |
| 36 | self.col[t] = self.col[t - 1] |
| 37 | |
| 38 | # Set new current point |
| 39 | self.row[0] = r |
| 40 | self.col[0] = c |
| 41 | |
| 42 | |
| 43 | class DotSimulator: |