Untitled
unknown
plain_text
3 years ago
658 B
2
Indexable
def _how_many_solutions_helper(picture: Picture, constraints_set: Set[ Constraint], n: int, m: int, index: int, counter=1) -> \ int: if index == n * m: return counter row, col = divmod(index, m) # define the row and column for a run. counter = _how_many_solutions_helper(picture, constraints_set, n, m, index + 1, counter) picture[row][col] = 1 - picture[row][col] counter += bool(check_constraints(picture, constraints_set)) counter = _how_many_solutions_helper(picture, constraints_set, n, m, index + 1, counter) picture[row][col] = 1 - picture[row][col] return counter
Editor is loading...