Anonymous user
Towers of Hanoi: Difference between revisions
m
→simple text moves: aligned the THEN-ELSE statements. -- ~~~~
m (→{{header|REXX}}: recoded MOV subroutine to use named arguments instead of numerated args, aligned the args in the calling of MOV. -- ~~~~) |
m (→simple text moves: aligned the THEN-ELSE statements. -- ~~~~) |
||
Line 1,624:
if z=='' then z=3 /*Not given? Use default 3 towers*/
move=0 /*number of ring moves so far. */
call mov 1,3,z /*move top ring, then recurse... */
say
say 'The minimum number of moves to solve a' z "ring Tower of Hanoi is"
exit /*stick a fork in it, we're done.*/
/*─────────────────────────────MOV subroutine───────────────────────────*/
mov: procedure expose move; arg #1, #2, #3
if #3==1 then call dsk #1, #2
return
/*─────────────────────────────DSK subroutine───────────────────────────*/
dsk: move=move+1
say 'step' right(move,length(moves))": move disk " arg(1) '──►' arg(2)
return</lang>
|