towers of hanoi; better variable naming
FossilOrigin-Name: dcbc4dc52e45f686490ce8d4c4e9b5cd9ffbbf2fad7e76ab5a2faff5023fa498
This commit is contained in:
parent
e8432b50a2
commit
4044f88cfa
1 changed files with 13 additions and 13 deletions
|
@ -1,20 +1,20 @@
|
|||
~~~
|
||||
'a var
|
||||
'b var
|
||||
'c var
|
||||
'n var
|
||||
'Num var
|
||||
'From var
|
||||
'To var
|
||||
'Via var
|
||||
|
||||
:vars !c !b !a !n ;
|
||||
:set-vars !Via !To !From !Num ;
|
||||
:hanoi (num,from,to,via-)
|
||||
vars
|
||||
@n n:-zero?
|
||||
set-vars
|
||||
@Num 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
|
||||
@Num @From @To @Via
|
||||
@Num n:dec @From @Via @To hanoi
|
||||
set-vars
|
||||
@To @From '\nMove_a_ring_from_%n_to_%n s:with-format puts
|
||||
@Num n:dec @Via @To @From hanoi
|
||||
] if ;
|
||||
|
||||
#5 #1 #3 #2 hanoi nl
|
||||
#3 #1 #3 #2 hanoi nl
|
||||
~~~
|
||||
|
|
Loading…
Reference in a new issue