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
| DICE = [['A','A','E','E','G','N'], | |
| ['E','L','R','T','T','Y'], | |
| ['A','O','O','T','T','W'], | |
| ['A','B','B','J','O','O'], | |
| ['E','H','R','T','V','W'], | |
| ['C','I','M','O','T','U'], | |
| ['D','I','S','T','T','Y'], | |
| ['E','I','O','S','S','T'], | |
| ['D','E','L','R','V','Y'], | |
| ['A','C','H','O','P','S'], |
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
| DICE = [['A','A','E','E','G','N'], | |
| ['E','L','R','T','T','Y'], | |
| ['A','O','O','T','T','W'], | |
| ['A','B','B','J','O','O'], | |
| ['E','H','R','T','V','W'], | |
| ['C','I','M','O','T','U'], | |
| ['D','I','S','T','T','Y'], | |
| ['E','I','O','S','S','T'], | |
| ['D','E','L','R','V','Y'], | |
| ['A','C','H','O','P','S'], |
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
| class Sudoku | |
| def initialize(sudoku_string) | |
| @sudoku = sudoku_string.split("").map {|elem| elem.to_i } | |
| 9.times { @sudoku << @sudoku.shift(9) } | |
| insert_possible_values | |
| end | |
| def solve! | |
| 100.times do | |
| @sudoku.each_with_index do |row, row_i| |
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
| DICE = [['A','A','E','E','G','N'], | |
| ['E','L','R','T','T','Y'], | |
| ['A','O','O','T','T','W'], | |
| ['A','B','B','J','O','O'], | |
| ['E','H','R','T','V','W'], | |
| ['C','I','M','O','T','U'], | |
| ['D','I','S','T','T','Y'], | |
| ['E','I','O','S','S','T'], | |
| ['D','E','L','R','V','Y'], | |
| ['A','C','H','O','P','S'], |
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
| CELL_POSSIBILITIES = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
| def print_sudoku(example) | |
| example.each do |line| | |
| line.each do |cell| | |
| print cell.to_s + " " | |
| end | |
| puts | |
| end | |
| end |
NewerOlder