aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-21 19:49:08 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2021-07-21 19:49:08 +0100
commit3bb04e46052861745a199c139ce89000f7f4bd74 (patch)
tree94bd2ef757e58747c8c35331b849e4dfa412e25b
parent0980d45083ced3aa736f0d90dbef5486f99ffca0 (diff)
parent2e3b1e9579f0b218fb7230b0c9e5bcb87e486fbb (diff)
downloadperlweeklychallenge-club-3bb04e46052861745a199c139ce89000f7f4bd74.tar.gz
perlweeklychallenge-club-3bb04e46052861745a199c139ce89000f7f4bd74.tar.bz2
perlweeklychallenge-club-3bb04e46052861745a199c139ce89000f7f4bd74.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
-rw-r--r--challenge-122/simon-proctor/raku/ch-1.raku19
-rw-r--r--challenge-122/simon-proctor/raku/ch-2.raku11
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-122/simon-proctor/raku/ch-1.raku b/challenge-122/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..5c685c3dd0
--- /dev/null
+++ b/challenge-122/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,19 @@
+#!/usr/bin/env raku
+
+sub avg($avg,$val) {
+ state $count = 1;
+ my $sum = $avg*$count;
+ $sum += $val;
+ $count++;
+ $sum / $count;
+}
+
+#| Given a list of numbers print the average of the list with each point in the list
+multi sub MAIN( *@N ) {
+ ( [\[&avg]] @N ).join(", ").say;
+}
+
+#| Read from STDIN and output the running average after each number
+multi sub MAIN() {
+ .say for [\[&avg]] $*IN.lines;
+}
diff --git a/challenge-122/simon-proctor/raku/ch-2.raku b/challenge-122/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..8487b83a62
--- /dev/null
+++ b/challenge-122/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,11 @@
+#!/usr/bin/env raku
+
+#| Given a number print all the possible ways to score that in basketball
+sub MAIN (Int() $N) {
+ .say for (|(1 xx $N), |(2 xx ($N div 2)), |(3 xx ($N div 3)))
+ .combinations(1..$N)
+ .unique(:with(&[eqv]))
+ .grep( -> @l { ([+] @l) ~~ $N } )
+ .map( -> @l { @l.permutations.unique(:with(&[eqv])).Slip } )
+ .map( *.join(",") )
+}