Task

Solve the   Towers of Hanoi   problem with recursion.




window 1, @"Towers of Hanoi", ( 0, 0, 300, 300 )
 
void local fn Move( n as long, fromPeg as long, toPeg as long, viaPeg as long )
  if n > 0
    fn Move( n-1, fromPeg, viaPeg, toPeg )
    print "Move disk from "; fromPeg; " to "; toPeg
    fn Move( n-1, viaPeg, toPeg, fromPeg )
  end if
end fn
 
fn Move( 4, 1, 2, 3 )
print
print "Towers of Hanoi puzzle solved."
 
HandleEvents