aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-04-20 18:52:49 +0100
committerGitHub <noreply@github.com>2024-04-20 18:52:49 +0100
commita35274e825f08cbd845c38e98a4dfc0686558861 (patch)
tree15546ad074e62ee11d9dbc4f01cc727f04b50975
parentcdf8415b097af3c94b7e5f879f810a03628d8493 (diff)
parente79fbc686abaf6ad8c8929c18c6153d880a6d9f4 (diff)
downloadperlweeklychallenge-club-a35274e825f08cbd845c38e98a4dfc0686558861.tar.gz
perlweeklychallenge-club-a35274e825f08cbd845c38e98a4dfc0686558861.tar.bz2
perlweeklychallenge-club-a35274e825f08cbd845c38e98a4dfc0686558861.zip
Merge pull request #9958 from wambash/challenge-week-265
solutions week 265
-rw-r--r--challenge-265/wambash/raku/ch-1.raku26
-rw-r--r--challenge-265/wambash/raku/ch-2.raku21
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-265/wambash/raku/ch-1.raku b/challenge-265/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..e294b53584
--- /dev/null
+++ b/challenge-265/wambash/raku/ch-1.raku
@@ -0,0 +1,26 @@
+#!/usr/bin/env raku
+use v6.e.PREVIEW;
+
+sub appearance (+ints, :$p=1/3) {
+ ints
+ andthen .Mix
+ andthen .nodemap: { $^x / $_ }\
+ andthen .grep: { .value ≥ $p }\
+ andthen .min: *.key
+ andthen .?key
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is appearance(1,2,3,3,3,3,4,2),3;
+ is appearance(1,1),1;
+ is appearance(1,2,3),1;
+ is appearance(1,2,3,4),Nil;
+ is appearance(1,2,3,4):p(1/4),1;
+ is appearance(3,4,5,5),5;
+ done-testing;
+}
+
+multi MAIN (+ints, :$p=1/3) {
+ say appearance ints, :$p
+}
diff --git a/challenge-265/wambash/raku/ch-2.raku b/challenge-265/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..44b0819767
--- /dev/null
+++ b/challenge-265/wambash/raku/ch-2.raku
@@ -0,0 +1,21 @@
+#!/usr/bin/env raku
+
+sub completing-word (+str,:$str) {
+ my %letters := $str.lc.comb(/<alpha>/).Bag;
+
+ str
+ andthen .grep: { .comb.Bag ⊇ %letters }\
+ andthen .min: *.chars
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is completing-word(<accbbb abc abbc>,:str('aBc 11c')),'accbbb';
+ is completing-word('abcm', 'baacd', 'abaadc',:str('Da2 abc')),'baacd';
+ is completing-word('jj', 'bb', 'bjb',:str('JB 007')),'bjb';
+ done-testing;
+}
+
+multi MAIN (+str,:$str) {
+ say completing-word +str,:$str
+}