Towers of Hanoi: Difference between revisions
Content added Content deleted
(→{{header|AppleScript}}: lang tag ++ amigae) |
(→{{header|Ruby}}: ++ R) |
||
Line 631: | Line 631: | ||
hanoi(ndisks=4)</lang> |
hanoi(ndisks=4)</lang> |
||
=={{header|R}}== |
|||
{{trans|Octave}} |
|||
<lang R>hanoimove <- function(ndisks, from, to, via) { |
|||
if ( ndisks == 1 ) |
|||
print(sprintf("move disk from %d to %d", from, to)) |
|||
else { |
|||
hanoimove(ndisks-1, from, via, to) |
|||
hanoimove(1, from, to, via) |
|||
hanoimove(ndisks-1, via, to, from) |
|||
} |
|||
} |
|||
hanoimove(4,1,2,3)</lang> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |