Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da79112 commit c9b0efaCopy full SHA for c9b0efa
csp.py
@@ -486,9 +486,12 @@ class Sudoku(CSP):
486
bgrid = [[[[Cell() for x in R3] for y in R3] for bx in R3] for by in R3]
487
boxes = flatten([map(flatten, brow) for brow in bgrid])
488
rows = flatten([map(flatten, zip(*brow)) for brow in bgrid])
489
- units = map(set, boxes + rows + zip(*rows))
490
- neighbors = dict([(v, set.union(*[u for u in units if v in u]) - set([v]))
491
- for v in flatten(rows)])
+ cols = zip(*rows)
+
+ neighbors = dict([(v, set()) for v in flatten(rows)])
492
+ for unit in map(set, boxes + rows + cols):
493
+ for v in unit:
494
+ neighbors[v].update(unit - set([v]))
495
496
def __init__(self, grid):
497
"""Build a Sudoku problem from a string representing the grid:
0 commit comments