Created
May 10, 2010 12:33
-
-
Save thomasfedb/395994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hidden_singles | |
changed = false | |
@groups.each do |group| | |
numbers = [] | |
group.each do |cell| | |
numbers = numbers + @possible[cell] unless @possible[cell].size == 1 | |
end | |
(1..9).to_a.each do |number| | |
if numbers.count(number) == 1 | |
# There is only one spot where number can go in this group. find it! | |
group.each do |cell| | |
if @possible[cell].member?(number) | |
@possible[cell] = [number] | |
@cell_groups[cell].each do |group| | |
@group_possible[group] = @group_possible[group] - @possible[cell] | |
@neiboughs[cell].each do |adjacent| | |
if @possible[adjacent].member?(@possible[cell]) | |
@possible[adjacent] = @possible[adjacent] - @possible[cell] | |
end | |
end | |
end | |
changed = true | |
end | |
end | |
end | |
end | |
end | |
changed | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment