Jump to content

Towers of Hanoi: Difference between revisions

Added TeX
m (Small cleanup)
(Added TeX)
Line 2,826:
14: move from A to C
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}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.