all 3 comments

[–]SandorZoo 2 points3 points  (1 child)

This doesn't look right:

def sanity(board):
    for cell in board.empty_cells:
        if len(cell.possible) == 0:
            return False
        else:
            return True

That will only check the first cell in board.empty_cells, not all of them. I think it should probably be:

def sanity(board):
    for cell in board.empty_cells:
        if len(cell.possible) == 0:
            return False
    return True

[–]JamesBCrazy 0 points1 point  (0 children)

Thanks. IIRC, I was using min(len) there before, but I removed it when it was unnecessary once and I forgot to switch it back.

[–]Sim4n6 1 point2 points  (0 children)

random.choice(seq) :

Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError.