Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Recursion: the Towers of Hanoi problem

by pg (Canon)
on Oct 19, 2004 at 04:07 UTC ( [id://400403]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub movedisks { #to make this move
    
  2. or download this
      my( $num, $from, $to, $aux ) = @_;
      if( $num == 1 ) {
        ;
      } else {
    
  3. or download this
        #you have to make those two moves first
        movedisks( $num-1, $from, $aux, $to );
        movedisks( $num-1, $aux, $to, $from );
    
  4. or download this
      }
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-28 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found