Last active
August 29, 2015 14:03
-
-
Save dylanerichards/3a1ae5d640fb577478e5 to your computer and use it in GitHub Desktop.
Sudoku 1 pseudocode
This file contains hidden or 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
☐ 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