aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-03-30 20:07:18 +0100
committerGitHub <noreply@github.com>2020-03-30 20:07:18 +0100
commit35801ee634de39fd2b8b59b293c1edcaebf87a0d (patch)
tree4b804e3ad9557d0fb6f4d420d71082b0a632a0ab
parent5b555b9a0982e8ec5a85c75157e5a2dd93ad5cda (diff)
parent340592c026f33b33d4334ce5ebd561a35b3c943e (diff)
downloadperlweeklychallenge-club-35801ee634de39fd2b8b59b293c1edcaebf87a0d.tar.gz
perlweeklychallenge-club-35801ee634de39fd2b8b59b293c1edcaebf87a0d.tar.bz2
perlweeklychallenge-club-35801ee634de39fd2b8b59b293c1edcaebf87a0d.zip
Merge pull request #1490 from Scimon/master
Here we go
-rw-r--r--challenge-054/simon-proctor/raku/ch-1.p68
-rw-r--r--challenge-054/simon-proctor/raku/ch-2.p614
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-054/simon-proctor/raku/ch-1.p6 b/challenge-054/simon-proctor/raku/ch-1.p6
new file mode 100644
index 0000000000..3670fe4fda
--- /dev/null
+++ b/challenge-054/simon-proctor/raku/ch-1.p6
@@ -0,0 +1,8 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| Print the kth permutation of the numbers from 1 to n
+sub MAIN( UInt \n, Int \k where * >= 1 ) {
+ (1..n).permutations[k-1].join("").say;
+}
diff --git a/challenge-054/simon-proctor/raku/ch-2.p6 b/challenge-054/simon-proctor/raku/ch-2.p6
new file mode 100644
index 0000000000..d5e06d7387
--- /dev/null
+++ b/challenge-054/simon-proctor/raku/ch-2.p6
@@ -0,0 +1,14 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| Print the Collatz list for target
+multi sub MAIN(
+ UInt \target #= Number to print the target for
+){
+ (target,{collatz($^a)}...1).join(' -> ').say;
+}
+
+multi sub collatz( UInt \n where { n %% 2 } ) { n div 2; }
+
+multi sub collatz( UInt \n where { n !%% 2 } ) { (3 * n) + 1; }