aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-09-11 02:29:33 +0100
committerGitHub <noreply@github.com>2023-09-11 02:29:33 +0100
commit42a5fd82138a8ca1223468318854075eee783248 (patch)
treef913911775b936e574b96732015e5c8845cd795d
parentdaf7ce6461a5387f0e4bf8cd05f12b156f6e1c71 (diff)
parent7e8c2a0cfbf5b1269fe8080279ee1410494cb538 (diff)
downloadperlweeklychallenge-club-42a5fd82138a8ca1223468318854075eee783248.tar.gz
perlweeklychallenge-club-42a5fd82138a8ca1223468318854075eee783248.tar.bz2
perlweeklychallenge-club-42a5fd82138a8ca1223468318854075eee783248.zip
Merge pull request #8683 from 2colours/branch-for-challenge-233
Weekly solutions for 2colours (Raku)
-rwxr-xr-xchallenge-233/2colours/raku/ch-1.raku8
-rwxr-xr-xchallenge-233/2colours/raku/ch-2.raku12
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-233/2colours/raku/ch-1.raku b/challenge-233/2colours/raku/ch-1.raku
new file mode 100755
index 0000000000..ab57b14f5c
--- /dev/null
+++ b/challenge-233/2colours/raku/ch-1.raku
@@ -0,0 +1,8 @@
+#!/usr/bin/env raku
+my token word { '"' <( .*? )> '"' }
+subset StringArray of Str where /^ \s* '(' \s* <word>* % [\s* ',' \s*] \s* ')' \s* $/;
+sub MAIN($input) {
+ die 'Please provide valid input.' unless $input ~~ StringArray;
+ my @input = $<word>;
+ @input>>.comb>>.Set.Bag.values.map({ $^n * ($^n - 1) div 2 }).sum.say;
+} \ No newline at end of file
diff --git a/challenge-233/2colours/raku/ch-2.raku b/challenge-233/2colours/raku/ch-2.raku
new file mode 100755
index 0000000000..d2737e3948
--- /dev/null
+++ b/challenge-233/2colours/raku/ch-2.raku
@@ -0,0 +1,12 @@
+#!/usr/bin/env raku
+
+my token integer { 0 | '-'? <[1..9]> <[0..9]>* }
+subset IntList of Str where /^ '(' <integer>* % ',' ')' $/; # The task didn't specify what a "list of numbers" should be - treating it as a list of integers
+
+sub MAIN(
+ $ints #= list of integer numbers
+) {
+ die 'Please provide valid input for @list' unless $ints.subst(/\s/, '', :g) ~~ IntList;
+ my Int() @ints = $<integer>;
+ @ints.Bag.classify(*.value, as => *.key)>>.sort(-*).sort(*.key).map({ .value<> Xxx .key }).flat.list.raku.say;
+} \ No newline at end of file