| 52 | EMPTY = "-" |
| 53 | |
| 54 | class Grid: |
| 55 | def __init__(self, height, width): |
| 56 | self.height = height |
| 57 | self.width = width |
| 58 | self.rows = [] |
| 59 | for _ in range(self.height): |
| 60 | self.rows.append([EMPTY] * self.width) |
| 61 | |
| 62 | def get(self, y, x): |
| 63 | return self.rows[y % self.height][x % self.width] |
| 64 | |
| 65 | def set(self, y, x, state): |
| 66 | self.rows[y % self.height][x % self.width] = state |
| 67 | |
| 68 | def __str__(self): |
| 69 | output = "" |
| 70 | for row in self.rows: |
| 71 | for cell in row: |
| 72 | output += cell |
| 73 | output += "\n" |
| 74 | return output |
| 75 | |
| 76 | |
| 77 | def count_neighbors(y, x, get_cell): |
no outgoing calls
no test coverage detected