Skip to content

Commit 2038798

Browse files
committedNov 26, 2020
Small bug fix
1 parent e0bb093 commit 2038798

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
 

‎__pycache__/candidates.cpython-38.pyc

0 Bytes
Binary file not shown.

‎candidates.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def update_candidates(board, candidates):
6969

7070

7171
updated_candidates = {}
72-
for cell, values in candidates.items():
72+
for cell, values in candidates.items(): #iterate through current candidates
7373
value_set = set()
7474
for val in values:
7575
if not board.is_valid_move(cell, val):
@@ -78,7 +78,7 @@ def update_candidates(board, candidates):
7878
value_set.add(val)
7979
updated_candidates[cell] = value_set
8080

81-
updated_bool = not updated_candidates == candidates
81+
updated_bool = not updated_candidates == candidates #True if no updates made
8282

8383
return updated_candidates, updated_bool
8484

@@ -101,14 +101,13 @@ def exhaust_candidates(board):
101101
#board_updates = 0
102102
while board_changed:
103103
board_changed = check_candidates(board, candidates)
104+
#if not board_changed: print("Final board:")
105+
#board.print()
104106
candidates, candidates_updated = update_candidates(board, candidates)
105107
#board_updates += 1
106108
#print("Board updates: ", board_updates)
107-
'''
108-
candidate_updates = 0
109-
while candidates_updated:
110-
candidates, candidates_updated = update_candidates(board, candidates)
111-
'''
109+
110+
112111
return candidates
113112

114113

‎main.py

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
***Candidate method cannot find solutions to the hard or
1515
insane boards***
1616
'''
17+
'''
18+
board = Board()
19+
20+
board.parse_board("boards/easy.txt")
21+
board.print()
22+
23+
cand = candidates.exhaust_candidates(board)
24+
25+
#board.print()
26+
'''
27+
28+
1729

1830
board = Board()
1931
puzzles = ["boards/easy.txt", "boards/medium.txt", "boards/hard.txt", "boards/insane.txt"]

0 commit comments

Comments
 (0)
Please sign in to comment.