aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-08-17 05:50:10 +0100
committerGitHub <noreply@github.com>2020-08-17 05:50:10 +0100
commita81cc45a50c0fbbb83761a115584f045b66dfc24 (patch)
treed951580207ae19b8422e422ba4d51639931ff9b2
parentbe31094a52b8d088203ed30e6ac3ea5c43af38f2 (diff)
parent26b6db21e84648652c374d46c5a9c7de5e862e17 (diff)
downloadperlweeklychallenge-club-a81cc45a50c0fbbb83761a115584f045b66dfc24.tar.gz
perlweeklychallenge-club-a81cc45a50c0fbbb83761a115584f045b66dfc24.tar.bz2
perlweeklychallenge-club-a81cc45a50c0fbbb83761a115584f045b66dfc24.zip
Merge pull request #2088 from andemark/branch-for-challenge-074
ch-1.raku
-rw-r--r--challenge-074/mark-anderson/raku/ch-1.raku21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-074/mark-anderson/raku/ch-1.raku b/challenge-074/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..f1bf76d679
--- /dev/null
+++ b/challenge-074/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,21 @@
+subset IntArray of Array where .all ~~ Int;
+
+subset NonEmptyIntArray of IntArray where .elems > 0;
+
+unit sub MAIN(*@integers where * ~~ NonEmptyIntArray);
+
+my $bag = bag @integers;
+
+my ($k, $v) = $bag.maxpairs.first.kv;
+
+my $t = $bag.total;
+
+if $v <= $t div 2 {
+ say "-1 as none of the elements appears more than floor($t/2)."
+}
+
+else {
+ my $s = do if $v == 1 { q{} } else { "s" }
+
+ say "$k, as $k appears $v time$s in the list which is more than floor($t/2)."
+}