Created
September 19, 2017 03:19
-
-
Save AlexDaniel/c1db30f0fce549d71c844fdfb6f70bd9 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') { | |
return 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