MCPcopy Index your code
hub / github.com/bslatkin/effectivepython / Grid

Class Grid

example_code/item_073.py:120–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 pass
119
120class Grid:
121 def __init__(self, height, width):
122 self.height = height
123 self.width = width
124 self.rows = []
125 for _ in range(self.height):
126 self.rows.append([EMPTY] * self.width)
127
128 def get(self, y, x):
129 return self.rows[y % self.height][x % self.width]
130
131 def set(self, y, x, state):
132 self.rows[y % self.height][x % self.width] = state
133
134 def __str__(self):
135 output = ""
136 for row in self.rows:
137 for cell in row:
138 output += cell
139 output += "\n"
140 return output
141
142
143def count_neighbors(y, x, get_cell):

Callers 2

simulate_pipelineFunction · 0.70
item_073.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected