Add initial classes and a couple of tests for Board
This commit is contained in:
commit
895a9dd01b
15 changed files with 160 additions and 0 deletions
29
src/board.cr
Normal file
29
src/board.cr
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
module Sudoku
|
||||
|
||||
class Board
|
||||
|
||||
alias Value = Nil | Int8
|
||||
|
||||
enum State
|
||||
Valid
|
||||
Invalid
|
||||
end
|
||||
|
||||
getter grid
|
||||
|
||||
def initialize(@width : Int8, @height : Int8)
|
||||
@grid = Array(Value).new(@width * @height, nil)
|
||||
end
|
||||
|
||||
def put(value : Value, x, y)
|
||||
@grid[y * @width + x] = value
|
||||
end
|
||||
|
||||
def get(x, y)
|
||||
@grid[y * @width + x]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue