Method: SudokuBuilder::Builder#poke
- Defined in:
- lib/sudoku_builder/builder.rb
#poke(number, poke_with = []) ⇒ Object
pokes holes in a built sudoku to make it solvable. arranged by level of difficulty.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sudoku_builder/builder.rb', line 31 def poke(number, poke_with = []) @sud.to_hash poke = [] until poke.count == number # number is related to difficulty. poke << rand(0..80) # 0 - 80 refers to the index of the sudoku cells. poke = poke.uniq end poke.each do |p| # pokes random holes. @sud[p] = poke_with end Builder.new(@sud) end |