Skip to content

Commit

Permalink
Fixed bug with naked pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
sotolf2 authored Oct 24, 2019
1 parent 5b5efda commit 74d2623
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def __naked_pair(self):
continue
pair_coords = self.__get_pair_coords(pairs)
for pair, cur_coords in pair_coords.items():
x, y = tuple(pair)
if len(cur_coords) == 2:
# Affecting row
x, y = tuple(pair)
rows = set([row for row,col in cur_coords])
if len(rows) == 1:
cells1 = coords + self.__get_row_coords(list(rows)[0])
Expand Down Expand Up @@ -166,6 +166,7 @@ def __naked_pair(self):
continue
pair_coords = self.__get_pair_coords(pairs)
for pair, cur_coords in pair_coords.items():
x, y = tuple(pair)
if len(cur_coords) == 2:
cells1 = coords
self.__create_pair_hint(x,y, cells1, cur_coords)
Expand All @@ -180,6 +181,7 @@ def __naked_pair(self):
continue
pair_coords = self.__get_pair_coords(pairs)
for pair, cur_coords in pair_coords.items():
x, y = tuple(pair)
if len(cur_coords) == 2:
cells1 = coords
self.__create_pair_hint(x, y, cells1, cur_coords)
Expand All @@ -193,7 +195,7 @@ def __create_pair_hint(self, x, y, cells1, cur_coords):
bad_cands = bad_x + bad_y
if not bad_cands:
return
self.hint = Hint("Naked pair {} {}".format(x, y), cells1, None, good_cands, bad_cands, "Naked pair")
self.hint = Hint("Naked pair {} {}".format(x, y), cells1, cur_coords, good_cands, bad_cands, "Naked pair")

def __get_pair_coords(self, pairs):
pair_coords = {}
Expand Down

0 comments on commit 74d2623

Please sign in to comment.