Towers of Hanoi: Difference between revisions

Line 1:
{{task|Classic CS problems and programs}}[[Category:Recursion]][[Category:Games]]
In this task, the goal is to solve the [[wp:Towers_of_Hanoi|Towers of Hanoi]] problem with recursion.
 
=={{header|8th}}==
<lang forth>
5 var, disks
var sa
var sb
var sc
 
: save sc ! sb ! sa ! disks ! ;
: get sa @ sb @ sc @ ;
: get2 get swap ;
: hanoi
save disks @ not if ;; then
disks @ get
disks @ n:1- get2 hanoi save
cr
" move a ring from " . sa @ . " to " . sb @ .
disks @ n:1- get2 rot hanoi
;
 
" Tower of Hanoi, with " . disks @ . " rings: " .
disks @ 1 2 3 hanoi cr bye
 
</lang>
 
=={{header|ActionScript}}==
Anonymous user