-
-
Save AlexDaniel/c31400216809502871b082ad79b67428 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
use nqp; | |
sub hanoi(int $n, $a = 'A', $b = 'B', $c = 'C') { | |
nqp::if(nqp::isgt_i($n, 0), | |
nqp::stmts( | |
(hanoi nqp::sub_i($n, 1), $a, $c, $b), | |
(nqp::say("Move disk $n from peg $a to peg $c")), | |
(hanoi nqp::sub_i($n, 1), $b, $a, $c))) | |
} | |
hanoi(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment