Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created September 19, 2017 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDaniel/ed05d0901eac888af299ec3ddea5dad4 to your computer and use it in GitHub Desktop.
Save AlexDaniel/ed05d0901eac888af299ec3ddea5dad4 to your computer and use it in GitHub Desktop.
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