Sha256: c18796ff2d0407b360b80a8e948cd637bd4a28044635b4583b3a11985ee8c814
Contents?: true
Size: 690 Bytes
Versions: 3
Compression:
Stored size: 690 Bytes
Contents
module Hanoi module Jane class ConstrainedTowers < RegularTowers def initialize discs = 3 super @base = 3 end def ternary rebased end def inspect i = super i[:ternary] = i.delete :binary i end def ConstrainedTowers.find_stack stacks:, from:, disc: nil, total: # if we're in the middle if from == 1 # we always move to the right on an even total if total % 2 == 0 return 2 else return 0 end end # otherwise we're at the edges and can only move to the middle 1 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanoi-jane-0.4.0 | lib/hanoi/jane/towers/constrained_towers.rb |
hanoi-jane-0.3.4 | lib/hanoi/jane/towers/constrained_towers.rb |
hanoi-jane-0.3.3 | lib/hanoi/jane/towers/constrained_towers.rb |