(* The Towers Of Hanoi                                 *)
(* Pascal                                              *)
(* Copyright (C) 1998 Amit Singh. All Rights Reserved. *)
(* http://hanoi.kernelthread.com                       *)
(*                                                     *)
(* Tested under p2c and the GNU Pascal compiler        *)

PROGRAM Hanoi(input, output);

VAR N:integer;

PROCEDURE dohanoi(N, Tfrom, Tto, Tusing : integer);
  BEGIN
    if N > 0 THEN
    BEGIN
      dohanoi(N-1, Tfrom, Tusing, Tto);
      writeln('move ', Tfrom:1, ' --> ', Tto:1);
      dohanoi(N-1, Tusing, Tto, Tfrom);
    END
  END;

BEGIN
  write('N = ? ');
  readln(N);
  writeln;
  dohanoi(N, 1, 3, 2)
END.

