Skip to content

Commit 8c31a50

Browse files
committed
Simpler ruby version
1 parent d1dcdb8 commit 8c31a50

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

ruby/hanoi_tower.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
a = Object.new.freeze
2-
b = Object.new.freeze
3-
c = Object.new.freeze
4-
51
def hanoi(n, from, mid, to)
62
return 1 if n == 1
73

84
hanoi(n - 1, from, to, mid) + 1 + hanoi(n - 1, mid, from, to)
95
end
106

11-
result = hanoi(32, a, b, c)
7+
result = hanoi(32, :a, :b, :c)
128
puts "#{result} moves"

0 commit comments

Comments
 (0)