Skip to content

Instantly share code, notes, and snippets.

@dylanerichards
Last active August 29, 2015 14:03
Show Gist options
  • Save dylanerichards/3a1ae5d640fb577478e5 to your computer and use it in GitHub Desktop.
Save dylanerichards/3a1ae5d640fb577478e5 to your computer and use it in GitHub Desktop.
Sudoku 1 pseudocode
☐ create variable containing options [1-9]
☐ look at first row and see what numbers from 1-9 are missing
☐ then look at column and see what else is missing
☐ finally, check the box
☐ (note that we're removing values from 'options' every time we check)
☐ compare what's missing to our options
☐ when options.size == 1, then we know that that's the answer
☐ if not, then move on to next empty cell
OPTIONS = [1,2,3,4,5,6,7,8,9]
for num in options
if row(0).to_a.include?(num)
OPTIONS.delete_if {|option| option.include?(num) }
end
column(4).to_a.include?(num)
☐ create an array of the submatrix
OPTIONS = [2,5]
☐ if OPTIONS.length == 1, then place option into empty spot, ELSE, reset options and proceed to next empty spot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment