Towers of Hanoi: Difference between revisions

Content added Content deleted
(Added TeX)
m (Moved from TeX to PlainTeX)
Line 2,038: Line 2,038:


end tower;</lang>
end tower;</lang>

=={{Header|PlainTeX}}==

<lang TeX>\newcount\hanoidepth
\def\hanoi#1{%
\hanoidepth = #1
\move abc
}%
\def\move#1#2#3{%
\advance \hanoidepth by -1
\ifnum \hanoidepth > 0
\move #1#3#2
\fi
Move the upper disk from pole #1 to pole #3.\par
\ifnum \hanoidepth > 0
\move#2#1#3
\fi
\advance \hanoidepth by 1
}

\hanoi{5}
\end</lang>


=={{header|PostScript}}==
=={{header|PostScript}}==
Line 2,826: Line 2,848:
14: move from A to C
14: move from A to C
15: move from B to C</pre>
15: move from B to C</pre>

=={{Header|TeX}}==

<lang TeX>\newcount\hanoidepth
\def\hanoi#1{%
\hanoidepth = #1
\move abc
}%
\def\move#1#2#3{%
\advance \hanoidepth by -1
\ifnum \hanoidepth > 0
\move #1#3#2
\fi
Move the upper disk from pole #1 to pole #3.\par
\ifnum \hanoidepth > 0
\move#2#1#3
\fi
\advance \hanoidepth by 1
}

\hanoi{5}
\end</lang>


=={{header|TI-83 BASIC}}==
=={{header|TI-83 BASIC}}==