Sha256: ec54d369fda217f9277cee5c7e93116afffa9fa015f1d73c52e8e6e2a4935920

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

module Hanoi
  module Jane
    class ConstrainedTowers < Towers
      def initialize discs
        super
        @base = 3

        @directions = {}
        @stacks[0].each do |disc|
          @directions[disc] = :right
        end
      end

      def ternary
        rebased
      end
      
      def find_stack
        case @source
        when 0
          @directions[@disc] = :right
          return 1
        when 2
          @directions[@disc] = :left
          return 1
        when 1
          if @directions[@disc] == :right
            return 2
          else
            return 0
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanoi-jane-0.1.0 lib/hanoi/jane/constrained_towers.rb