Skip to content

Commit

Permalink
Things that occur to you in the bath
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Nov 25, 2017
1 parent e529865 commit 6c230e1
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lib/hanoi/jane/constrained_towers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ class ConstrainedTowers < Towers
def initialize discs
super
@base = 3

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

def ternary
Expand All @@ -17,30 +12,24 @@ def ternary

def inspect
i = super

i.delete :binary
i[:ternary] = rebased

i[:ternary] = i.delete :binary
i
end

private

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
# if we're in the middle
if @source == 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
Expand Down

0 comments on commit 6c230e1

Please sign in to comment.