*** empty log message ***
[chuck-blob.git] / v2 / examples / hanoi.ck
blob80458eebfbc955457a8593d4d5e418b17e1696f5
1 // towers of annoy : non-sonified version
3 // number of disks
4 10 => int disks;
6 // moves
7 0 => int moves;
9 // the hanoi
10 fun void hanoi( int num, int src, int dest, int other )
12     // stop here
13     if( num <= 0 ) return;
15     // move all except the biggest
16     hanoi( num - 1, src, other, dest );
17     // move the biggest
18     <<< "move disk from peg", src, " -> ", "peg", dest, ": #", ++moves >>>;
19     // move onto the biggest
20     hanoi( num - 1, other, dest, src );
23 // start it
24 hanoi( disks, 1, 3, 2 );
26 <<<"done!">>>;