aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Sommer <arne@bbop.org>2025-09-03 22:01:43 +0200
committerArne Sommer <arne@bbop.org>2025-09-03 22:01:43 +0200
commitfa7b3b9dd3943a58a10d4ad915f8d26da0bcba82 (patch)
tree0cf2c79ceea081e1bf73f9372bbdaa7495b95187
parent51a44734d81f4ed05aedb159f9bab3f3609ccbca (diff)
downloadperlweeklychallenge-club-fa7b3b9dd3943a58a10d4ad915f8d26da0bcba82.tar.gz
perlweeklychallenge-club-fa7b3b9dd3943a58a10d4ad915f8d26da0bcba82.tar.bz2
perlweeklychallenge-club-fa7b3b9dd3943a58a10d4ad915f8d26da0bcba82.zip
week 337 Arne Sommer
-rw-r--r--challenge-337/arne-sommer/blog.txt1
-rwxr-xr-xchallenge-337/arne-sommer/raku/ch-1.raku6
-rwxr-xr-xchallenge-337/arne-sommer/raku/ch-2.raku26
-rwxr-xr-xchallenge-337/arne-sommer/raku/odd-matrix26
-rwxr-xr-xchallenge-337/arne-sommer/raku/smaller-than-current6
5 files changed, 65 insertions, 0 deletions
diff --git a/challenge-337/arne-sommer/blog.txt b/challenge-337/arne-sommer/blog.txt
new file mode 100644
index 0000000000..9286424601
--- /dev/null
+++ b/challenge-337/arne-sommer/blog.txt
@@ -0,0 +1 @@
+https://raku-musings.com/oddly-current.html \ No newline at end of file
diff --git a/challenge-337/arne-sommer/raku/ch-1.raku b/challenge-337/arne-sommer/raku/ch-1.raku
new file mode 100755
index 0000000000..38cc36f59f
--- /dev/null
+++ b/challenge-337/arne-sommer/raku/ch-1.raku
@@ -0,0 +1,6 @@
+#! /usr/bin/env raku
+
+unit sub MAIN (*@num1 where @num1.elems > 0 && all(@num1) ~~ Numeric);
+
+say @num1.map({ @num1.grep( * <= $_ ).elems -1 });
+
diff --git a/challenge-337/arne-sommer/raku/ch-2.raku b/challenge-337/arne-sommer/raku/ch-2.raku
new file mode 100755
index 0000000000..e64648c2f2
--- /dev/null
+++ b/challenge-337/arne-sommer/raku/ch-2.raku
@@ -0,0 +1,26 @@
+#! /usr/bin/env raku
+
+unit sub MAIN (*@locations where @locations.elems > 0
+ && all(@locations) ~~ /^\d+\,\d+$/,
+ UInt :r(:$row) where $row > 0,
+ UInt :c(:$col) where $col > 0,
+ :v(:$verbose));
+
+my @matrix = [0 xx $col] xx $row;
+
+say ": Initial matrix: { @matrix.raku }" if $verbose;
+
+for @locations -> $location
+{
+ my ($r, $c) = $location.split(',');
+
+ die "Row $r is out of scope" if $r > $row;
+ die "Col $c is out of scope" if $c > $col;
+
+ @matrix[$r][$_]++ for ^$col;
+ @matrix[$_][$c]++ for ^$row;
+
+ say ": Row: $r, Col: $c -> { @matrix.raku }" if $verbose;
+}
+
+say @matrix[*;*].grep( ! ( * %% 2 ) ).elems;
diff --git a/challenge-337/arne-sommer/raku/odd-matrix b/challenge-337/arne-sommer/raku/odd-matrix
new file mode 100755
index 0000000000..e64648c2f2
--- /dev/null
+++ b/challenge-337/arne-sommer/raku/odd-matrix
@@ -0,0 +1,26 @@
+#! /usr/bin/env raku
+
+unit sub MAIN (*@locations where @locations.elems > 0
+ && all(@locations) ~~ /^\d+\,\d+$/,
+ UInt :r(:$row) where $row > 0,
+ UInt :c(:$col) where $col > 0,
+ :v(:$verbose));
+
+my @matrix = [0 xx $col] xx $row;
+
+say ": Initial matrix: { @matrix.raku }" if $verbose;
+
+for @locations -> $location
+{
+ my ($r, $c) = $location.split(',');
+
+ die "Row $r is out of scope" if $r > $row;
+ die "Col $c is out of scope" if $c > $col;
+
+ @matrix[$r][$_]++ for ^$col;
+ @matrix[$_][$c]++ for ^$row;
+
+ say ": Row: $r, Col: $c -> { @matrix.raku }" if $verbose;
+}
+
+say @matrix[*;*].grep( ! ( * %% 2 ) ).elems;
diff --git a/challenge-337/arne-sommer/raku/smaller-than-current b/challenge-337/arne-sommer/raku/smaller-than-current
new file mode 100755
index 0000000000..38cc36f59f
--- /dev/null
+++ b/challenge-337/arne-sommer/raku/smaller-than-current
@@ -0,0 +1,6 @@
+#! /usr/bin/env raku
+
+unit sub MAIN (*@num1 where @num1.elems > 0 && all(@num1) ~~ Numeric);
+
+say @num1.map({ @num1.grep( * <= $_ ).elems -1 });
+