Class: Xudoku::Deducer
Overview
:nodoc:
Instance Attribute Summary collapse
-
#allowed ⇒ Object
Returns the value of attribute allowed.
-
#board ⇒ Object
Returns the value of attribute board.
-
#count ⇒ Object
Returns the value of attribute count.
-
#guess ⇒ Object
Returns the value of attribute guess.
-
#needed ⇒ Object
Returns the value of attribute needed.
-
#stuck ⇒ Object
Returns the value of attribute stuck.
Instance Method Summary collapse
- #deduce ⇒ Object
-
#initialize(board) ⇒ Deducer
constructor
A new instance of Deducer.
Methods included from Utils
#bits_to_numbers, #guesses_from, #pick_better, #pos
Constructor Details
#initialize(board) ⇒ Deducer
Returns a new instance of Deducer.
10 11 12 13 |
# File 'lib/xudoku/deducer.rb', line 10 def initialize(board) @board = board reset! end |
Instance Attribute Details
#allowed ⇒ Object
Returns the value of attribute allowed.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def allowed @allowed end |
#board ⇒ Object
Returns the value of attribute board.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def board @board end |
#count ⇒ Object
Returns the value of attribute count.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def count @count end |
#guess ⇒ Object
Returns the value of attribute guess.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def guess @guess end |
#needed ⇒ Object
Returns the value of attribute needed.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def needed @needed end |
#stuck ⇒ Object
Returns the value of attribute stuck.
8 9 10 |
# File 'lib/xudoku/deducer.rb', line 8 def stuck @stuck end |
Instance Method Details
#deduce ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/xudoku/deducer.rb', line 15 def deduce loop do reset! return [] unless deduce_cells return [] unless deduce_all_axes @guess&.shuffle! return @guess if @stuck end end |