Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from utils import *
- from collections import Counter
- def only_choice(values):
- """Finalize all values that are the only choice for a unit.
- Go through all the units, and whenever there is a unit with a value
- that only fits in one box, assign the value to this box.
- Input: Sudoku in dictionary form.
- Output: Resulting Sudoku in dictionary form after filling in only choices.
- """
- # TODO: Implement only choice strategy here
- # display(values)
- for unit in unitlist:
- c = Counter()
- for box in unit:
- c.update(values[box])
- for box in unit:
- for value in values[box]:
- if c[value] == 1 and len(values[box]) > 1:
- values[box] = value
- return values
Add Comment
Please, Sign In to add comment