Class: Container
- Inherits:
-
Object
- Object
- Container
- Defined in:
- lib/sudoku_solver/container.rb
Instance Attribute Summary collapse
-
#arr ⇒ Object
Returns the value of attribute arr.
-
#remaining_blocks ⇒ Object
Returns the value of attribute remaining_blocks.
Instance Method Summary collapse
- #complete ⇒ Object
- #contain?(num) ⇒ Boolean
-
#difference ⇒ Object
Find the missing elements in the section.
-
#initialize(arr) ⇒ Container
constructor
A new instance of Container.
- #pencil_in ⇒ Object
- #remaining ⇒ Object
Constructor Details
#initialize(arr) ⇒ Container
Returns a new instance of Container.
4 5 6 |
# File 'lib/sudoku_solver/container.rb', line 4 def initialize(arr) @arr = arr end |
Instance Attribute Details
#arr ⇒ Object
Returns the value of attribute arr.
3 4 5 |
# File 'lib/sudoku_solver/container.rb', line 3 def arr @arr end |
#remaining_blocks ⇒ Object
Returns the value of attribute remaining_blocks.
3 4 5 |
# File 'lib/sudoku_solver/container.rb', line 3 def remaining_blocks @remaining_blocks end |
Instance Method Details
#complete ⇒ Object
30 31 32 33 34 |
# File 'lib/sudoku_solver/container.rb', line 30 def complete if remaining.count == 1 arr.map { |elem| elem == 0 ? remaining.first : elem } end end |
#contain?(num) ⇒ Boolean
21 22 23 24 |
# File 'lib/sudoku_solver/container.rb', line 21 def contain?(num) complete arr.include? num end |
#difference ⇒ Object
Find the missing elements in the section
8 9 10 11 |
# File 'lib/sudoku_solver/container.rb', line 8 def difference complete remaining end |
#pencil_in ⇒ Object
26 27 |
# File 'lib/sudoku_solver/container.rb', line 26 def pencil_in end |
#remaining ⇒ Object
13 14 15 |
# File 'lib/sudoku_solver/container.rb', line 13 def remaining Array(1..9) - arr end |