aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-05-10 11:07:06 +0100
committerGitHub <noreply@github.com>2021-05-10 11:07:06 +0100
commit326bbf2e68b8acc25c941e54f585d819f433ef45 (patch)
tree6bb64be0ad3d0f9e395777f31eb3055ff2864e61
parent7c3e4b829100a613a3dc05c4a378c351f2bfcced (diff)
parent533e40116001cb17b3f5b6f7a0f714bbcb0e2bd2 (diff)
downloadperlweeklychallenge-club-326bbf2e68b8acc25c941e54f585d819f433ef45.tar.gz
perlweeklychallenge-club-326bbf2e68b8acc25c941e54f585d819f433ef45.tar.bz2
perlweeklychallenge-club-326bbf2e68b8acc25c941e54f585d819f433ef45.zip
Merge pull request #4051 from andemark/branch-for-challenge-112
Branch for challenge 112
-rw-r--r--challenge-112/mark-anderson/raku/ch-1.raku10
-rw-r--r--challenge-112/mark-anderson/raku/ch-2.raku137
2 files changed, 147 insertions, 0 deletions
diff --git a/challenge-112/mark-anderson/raku/ch-1.raku b/challenge-112/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..9e7a0b29ef
--- /dev/null
+++ b/challenge-112/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,10 @@
+#!/usr/bin/env raku
+
+use Test;
+plan 3;
+
+is IO::Spec::Unix.canonpath("/a/"), "/a";
+
+is IO::Spec::Unix.canonpath("/a/b//c/"), "/a/b/c";
+
+is IO::Spec::Unix.canonpath("/a/b/c/../..", :parent), "/a";
diff --git a/challenge-112/mark-anderson/raku/ch-2.raku b/challenge-112/mark-anderson/raku/ch-2.raku
new file mode 100644
index 0000000000..7a4edaffde
--- /dev/null
+++ b/challenge-112/mark-anderson/raku/ch-2.raku
@@ -0,0 +1,137 @@
+#!/usr/bin/env raku
+
+multi MAIN
+{
+ use Test;
+ plan 6;
+
+ is stairs(3).elems, 3;
+
+ is stairs(4).elems, 5;
+
+ is stairs(10).elems, 89;
+
+ is-deeply stairs(3), ((1, 1, 1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1, 2, 2, 2, 1),
+ (2, 2, 1, 1, 1, 1, 1, 1),
+ (2, 2, 1, 1, 1, 1, 2),
+ (2, 2, 1, 1, 1, 2, 1),
+ (2, 2, 1, 1, 2, 1, 1),
+ (2, 2, 1, 1, 2, 2),
+ (2, 2, 1, 2, 1, 1, 1),
+ (2, 2, 1, 2, 1, 2),
+ (2, 2, 1, 2, 2, 1),
+ (2, 2, 2, 1, 1, 1, 1),
+ (2, 2, 2, 1, 1, 2),
+ (2, 2, 2, 1, 2, 1),
+ (2, 2, 2, 2, 1, 1),
+ (2, 2, 2, 2, 2))>>.Seq;
+}
+
+multi MAIN(UInt $u)
+{
+ my $seq := stairs($u);
+
+ say $seq.elems;
+
+ .say for $seq;
+}
+
+sub stairs(UInt $u)
+{
+ my $head = ('100' x $u).substr(0, $u).parse-base(2);
+ my $tail = ('110' x $u).substr(0, $u).parse-base(2);
+
+ ($head..$tail).map({
+ my $b = .base(2);
+
+ unless $b ~~ /000||111/
+ {
+ $b.comb(/(.)$0?/).map(*.chars)
+ }
+ }).sort
+}