MCPcopy Index your code
hub / github.com/python/cpython / _init_board

Method _init_board

Lib/test/test_generators.py:2233–2247  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2231 return divmod(index, self.n)
2232
2233 def _init_board(self):
2234 succs = self.succs
2235 del succs[:]
2236 m, n = self.m, self.n
2237 c2i = self.coords2index
2238
2239 offsets = [( 1, 2), ( 2, 1), ( 2, -1), ( 1, -2),
2240 (-1, -2), (-2, -1), (-2, 1), (-1, 2)]
2241 rangen = range(n)
2242 for i in range(m):
2243 for j in rangen:
2244 s = [c2i(i+io, j+jo) for io, jo in offsets
2245 if 0 <= i+io < m and
2246 0 <= j+jo < n]
2247 succs.append(s)
2248
2249 # Generate solutions.
2250 def solve(self):

Callers 1

solveMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected