towers of hanoi; better variable naming

FossilOrigin-Name: dcbc4dc52e45f686490ce8d4c4e9b5cd9ffbbf2fad7e76ab5a2faff5023fa498
This commit is contained in:
crc 2017-10-22 17:45:28 +00:00
parent e8432b50a2
commit 4044f88cfa

View file

@ -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
~~~