aboutsummaryrefslogtreecommitdiff
path: root/challenge-055
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-04-12 21:13:12 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-04-12 21:13:12 +0100
commit543521ef78a352aa40392d0aecd93463c3e096ea (patch)
treeeefe407489ab87d72f7ccaf31e30e6148aeda090 /challenge-055
parent0af674e3e44c30596d21a250f00c1fa9b01178a8 (diff)
downloadperlweeklychallenge-club-543521ef78a352aa40392d0aecd93463c3e096ea.tar.gz
perlweeklychallenge-club-543521ef78a352aa40392d0aecd93463c3e096ea.tar.bz2
perlweeklychallenge-club-543521ef78a352aa40392d0aecd93463c3e096ea.zip
- Added solutions by Shahed Nooshmand.
Diffstat (limited to 'challenge-055')
-rw-r--r--challenge-055/shahed-nooshmand/blog.txt1
-rw-r--r--challenge-055/shahed-nooshmand/raku/ch-1.p614
-rw-r--r--challenge-055/shahed-nooshmand/raku/ch-2.sh1
3 files changed, 16 insertions, 0 deletions
diff --git a/challenge-055/shahed-nooshmand/blog.txt b/challenge-055/shahed-nooshmand/blog.txt
new file mode 100644
index 0000000000..333774ba45
--- /dev/null
+++ b/challenge-055/shahed-nooshmand/blog.txt
@@ -0,0 +1 @@
+https://rafraichisso.ir/2020/04/11/pwc-55
diff --git a/challenge-055/shahed-nooshmand/raku/ch-1.p6 b/challenge-055/shahed-nooshmand/raku/ch-1.p6
new file mode 100644
index 0000000000..966f6fef5e
--- /dev/null
+++ b/challenge-055/shahed-nooshmand/raku/ch-1.p6
@@ -0,0 +1,14 @@
+#!/usr/bin/env raku
+
+multi postcircumfix:<[ ]> (Str $_, Range \ran) { .substr(ran) }
+
+my $num = “010”;
+my %flips;
+
+for ^$num.chars -> $L {
+ for $L..^$num.chars -> $R {
+ %flips{“$L\t$R”} = +($num[^$L] ~ (TR/01/10/ given $num[$L..$R]) ~ $num[$R^..*]).comb.grep: 1
+ }
+}
+
+say .key for %flips.grep: *.value == max %flips.values
diff --git a/challenge-055/shahed-nooshmand/raku/ch-2.sh b/challenge-055/shahed-nooshmand/raku/ch-2.sh
new file mode 100644
index 0000000000..1850dae331
--- /dev/null
+++ b/challenge-055/shahed-nooshmand/raku/ch-2.sh
@@ -0,0 +1 @@
+raku -e '.put for (my \N = [1, 2, 3, 4]).permutations.grep: { all do $_[0](|$_[1]) for |(&infix:«≥», &infix:«≤») xx * Z ($^n[^(*−1)] Z $^n[1..*]) }'