Skip to content

Instantly share code, notes, and snippets.

@andmcgregor
andmcgregor / gist:5737633
Created June 9, 2013 04:24
Brute force boggle
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'],
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'],
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|
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'],
@andmcgregor
andmcgregor / gist:5453318
Created April 24, 2013 16:05
First attempt at sudoku solver.
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