kernelthread.com

troff

The Towers of Hanoi implemented using troff.

The groff (GNU Troff) software is a typesetting package which reads plain text mixed with formatting commands and produces formatted output. Groff also supports HTML.

Click here to go to the Troff User's Manual.

\" The Towers Of Hanoi \" troff \" Copyright (C) 1999 Amit Singh. All Rights Reserved. \" http://hanoi.kernelthread.com \" \" Usage "troff -a hanoi.troff" \" Define a sane upper limit on the maximum number of disks permissible .nr M 10 .de usage usage: \.Hanoi(N), where N is a positive integer (0 < N <= \nM) .. \" doHanoi(N, from, using, to) \" Recursive macro to solve Towers Of Hanoi \" .de doHanoi .if \\$1 \{ \" (N > 0) \" move (N - 1): 'from' to 'using' using 'to' .doHanoi \\$1-1 \\$2 \\$4 \\$3 \\$2 --> \\$4 \" move (N - 1): 'using' to 'to' using 'from' .doHanoi \\$1-1 \\$3 \\$2 \\$4 \} .el \{ \" (N <= 0) \\$2 --> \\$4 \} .. \" Hanoi(N) \" * Wrapper macro for calling doHanoi \" * N is a positive integer (< \nM, for the sake of sanity) \" .de Hanoi .ie \\$1 \{ \" (N > 0) .ie \\$1-\nM \{ \" (N > \nM) .usage \} .el .doHanoi \\$1 1 2 3 \} \" (N <= 0) .el .usage .. \" Use the Hanoi macro .Hanoi 3

Download

hanoi.troff