aboutsummaryrefslogtreecommitdiff
path: root/challenge-054/simon-proctor/raku/ch-1.p6
blob: 89c7dcf40143b89319c10020dca3cfaef42b574e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env raku

use v6;

#| Print the kth permutation of the numbers from 1 to n
multi sub MAIN( UInt \n, Int \k where { 1 <= k <= [*] 1..n } ) {
    (1..n).permutations[k-1].join("").say;
}

multi sub MAIN( *@ ) is hidden-from-USAGE {
    say $*USAGE;
    say "\nPlease ensure k is between 1 and n!";
}