towers of hanoi solver
FossilOrigin-Name: 27e9fbb70fc8c2dce373b7255089083ddb5687c0dd893a5d9f10ac06e304e807
This commit is contained in:
parent
567d4fb490
commit
4b5967cf5d
1 changed files with 20 additions and 0 deletions
20
example/hanoi.forth
Normal file
20
example/hanoi.forth
Normal file
|
@ -0,0 +1,20 @@
|
|||
~~~
|
||||
'a var
|
||||
'b var
|
||||
'c var
|
||||
'n var
|
||||
|
||||
:vars !c !b !a !n ;
|
||||
:hanoi (num,from,to,via-)
|
||||
vars
|
||||
@n n:-zero?
|
||||
[
|
||||
@n @a @b @c
|
||||
@n n:dec @a @c @b hanoi
|
||||
vars
|
||||
@b @a '\nMove_a_ring_from_%n_to_%n s:with-format puts
|
||||
@n n:dec @c @b @a hanoi
|
||||
] if ;
|
||||
|
||||
#5 #1 #3 #2 hanoi nl
|
||||
~~~
|
Loading…
Reference in a new issue