Add to_s to Board

This commit is contained in:
Alberto Venturini 2019-11-01 19:02:20 +02:00
parent d573aad4f2
commit c8ee8c311e
4 changed files with 72 additions and 0 deletions

View file

@ -57,6 +57,23 @@ module Sudoku
}
}
end
# Convert a board to its string representation
def to_s
@grid.map { |row|
row.map { |cell|
case cell
when Nil
'.'
else cell.to_s
end
}.join
}.join("\n")
end
def solved?
@grid.flatten.none? { |i| i == nil }
end
end

View file

@ -1,6 +1,8 @@
module Sudoku
class Solver
def self.solve(board)
end
end
end