Towers of Hanoi: Difference between revisions
Content added Content deleted
m (Small cleanup) |
(Added TeX) |
||
Line 2,826: | Line 2,826: | ||
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}}== |