Class: Kudo::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/kudo/converter.rb

Class Method Summary collapse

Class Method Details

.convert_to_array(sudoku_string) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/kudo/converter.rb', line 5

def self.convert_to_array(sudoku_string)
  sudoku_string
    .split("")
    .select { |char| "0" <= char && char <= "9" }
    .map(&:to_i)
    .each_slice(9)
    .to_a
end

.convert_to_string(sudoku_grid) ⇒ Object



14
15
16
17
18
# File 'lib/kudo/converter.rb', line 14

def self.convert_to_string(sudoku_grid)
  sudoku_grid
    .map { |row| row.join(" ") }
    .join("\n")
end