예제 #1
0
def main():
    width = height = 6
    grid = generator.generate_puzzle(width, height)
    display(width, height, grid)
    grid = generate_puzzle(width, height, grid)
    display(width, height, grid)
    grid = naive.solve(width, height, grid)
    display(width, height, grid)
    grid = solver.solve(width, height, grid)
    display(width, height, grid)
예제 #2
0
def solve(width, height, grid):
    grid = naive.solve(width, height, grid)
    if grid.count(0) == 0:
        return grid
    generator = _solve1(width, height, grid)
    try:
        result = generator.next()
    except StopIteration:
        raise Exception('No solutions exist.')
    try:
        generator.next()
    except StopIteration:
        return result
    raise Exception('Multiple solutions exist.')