Towers of Hanoi: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 201:
 
hanoi(ndisks=4)
</pre>
 
==[[Ruby]]==
[[Category:Ruby]]
 
<pre>
def hanoi n,a='left',b='middle',c='right'
return if n==0
hanoi (n-1),a,c,b
puts "Move from #{a} to #{b}"
hanoi (n-1),c,b,a
end
</pre>
 
Anonymous user