Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Recursion: the Towers of Hanoi problem

by abitkin (Monk)
on Oct 25, 2004 at 14:38 UTC ( #402234=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub a{if(my$l=pop){a(@_[0,2,1],$l-1);print"Move disc $l from $_[0] to 
    +$_[2]
    ";a(@_[1,0,2],$l-1);}}a 'A'..'C',pop;
    
  2. or download this
    sub a{my$l=pop;a(@_[0,2,1],--$l)."Move disc $l from $_[0] to $_[2]
    ".a(@_[1,0,2],$l)if$l>0;}print a 'A'..'C',pop;
    
  3. or download this
    sub a{if(my$l=pop){a(@_[0,2,1],--$l);print"Move disc $l from $_[0] to 
    +$_[2]
    ";a(@_[1,0,2],$l);}}a 'A'..'C',pop;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://402234]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-08-28 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls