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
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 |
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
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 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 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 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 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
puts "\033[92m" + "Green = First letter" + "\033[0m" | |
puts "\033[91m" + "Red = Second letter" + "\033[0m" | |
puts "\033[93m" + "Yellow = Third letter" + "\033[0m" | |
puts "\033[94m" + "Blue = Fourth letter" + "\033[0m" if !trace[3].nil? | |
puts "\033[95m" + "Pink = Fifth letter" + "\033[0m" if !trace[4].nil? |
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 green | |
"\033[92m" + yield + "\033[0m" | |
end |
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
class SudokuCell | |
attr_accessor :index, :value, :row, :column, :box | |
def initialize(initial_value, index) | |
@value = initial_value != 0 ? initial_value : 0 | |
@index = index.to_i | |
@row = (0..81).to_a[((index/9)*9..(index/9)*9+8)] | |
@column, at_index, incrementor = [], index, +9 | |
until @column.count == 9 do | |
if at_index < 0 | |
incrementor = +9 |
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
# encoding: utf-8 |
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
DELETE FROM voters | |
WHERE homeowner = 1 | |
AND employed = 1 | |
AND children_count = 0 | |
AND party_duration < 3 | |
AND (SELECT voters.id | |
FROM voters | |
INNER JOIN votes | |
ON voters.id = votes.voter_id | |
INNER JOIN congress_members |
OlderNewer