Towers of Hanoi: Difference between revisions
Content deleted Content added
Added Dyalect programming language |
|||
Line 1,137: | Line 1,137: | ||
lrx # run() |
lrx # run() |
||
</pre> |
</pre> |
||
=={{header|Dyalect}}== |
|||
{{trans|Swift}} |
|||
<lang dyalect>func hanoi(n, a, b, c) { |
|||
if n > 0 { |
|||
hanoi(n - 1, a, c, b) |
|||
print("Move disk from \(a) to \(c)") |
|||
hanoi(n - 1, b, a, c) |
|||
} |
|||
} |
|||
hanoi(4, "A", "B", "C")</lang> |
|||
{{out}} |
|||
<pre>Move disk from A to B |
|||
Move disk from A to C |
|||
Move disk from B to C |
|||
Move disk from A to B |
|||
Move disk from C to A |
|||
Move disk from C to B |
|||
Move disk from A to B |
|||
Move disk from A to C |
|||
Move disk from B to C |
|||
Move disk from B to A |
|||
Move disk from C to A |
|||
Move disk from B to C |
|||
Move disk from A to B |
|||
Move disk from A to C |
|||
Move disk from B to C</pre> |
|||
=={{header|E}}== |
=={{header|E}}== |
||
Line 1,148: | Line 1,180: | ||
move(stdout, 4, def left {}, def right {}, def middle {})</lang> |
move(stdout, 4, def left {}, def right {}, def middle {})</lang> |
||
=={{header|Easyprog.online}}== |
=={{header|Easyprog.online}}== |
||