Skip to content

Instantly share code, notes, and snippets.

@fabianuribe
Last active December 20, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianuribe/6041795 to your computer and use it in GitHub Desktop.
Save fabianuribe/6041795 to your computer and use it in GitHub Desktop.
sudoku_string = "003020600900305001001806400008102900700000008006708200002609500800203009005010300"
sudoku_array = sudoku_string.split('')
rows_array = Array.new(9){ sudoku_array.shift(9) }
rows_array.each{|row| p row}
box_rows_array = []
# p rows_array
rows_array.each_with_index do |row, index|
box_rows_array += Array.new(3){row.shift(3)}
end
# box_rows_array.each{|row| p row}
def get_all_items_in_box(box_number, box_rows_array)
box_array = [box_rows_array[box_number], box_rows_array[box_number + 3], box_rows_array[box_number + 6]]
end
def print_box (box_number, box_rows_array)
puts
get_all_items_in_box(box_number, box_rows_array).each {|row| p row }
end
def get_all_items_
print_box(0, box_rows_array)
p get_all_items_in_box(0, box_rows_array).flatten.count('0')
# p print_box(2, box_rows_array)
# p print_box(3, box_rows_array)
# p print_box(4, box_rows_array)
# p print_box(5, box_rows_array)
# p print_box(6, box_rows_array)
# # (0..box_rows_array).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment