-
-
Save AlexDaniel/ed05d0901eac888af299ec3ddea5dad4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub hanoi($n, $a = 'A', $b = 'B', $c = 'C') { | |
if $n != 0 { | |
hanoi $n - 1, $a, $c, $b; | |
say "Move disk $n from peg $a to peg $c"; | |
hanoi $n - 1, $b, $a, $c; | |
} | |
} | |
hanoi(18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment