Module: SudokuSolver::Cell
- Defined in:
- lib/sudoku_solver/grid.rb
Instance Attribute Summary collapse
-
#grid ⇒ Object
Returns the value of attribute grid.
Instance Method Summary collapse
Instance Attribute Details
#grid ⇒ Object
Returns the value of attribute grid.
5 6 7 |
# File 'lib/sudoku_solver/grid.rb', line 5 def grid @grid end |
Instance Method Details
#neighbours ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/sudoku_solver/grid.rb', line 7 def neighbours sx = x - x % grid.dimension sy = y - y % grid.dimension neighbours_values = [ grid[grid.size, y], grid[x, grid.size], grid[sx..(sx + grid.dimension - 1), sy..(sy + grid.dimension - 1)] ]. inject([]) { |r, z| r + z.to_a }.flatten.uniq.reject { |d| d == self } end |