aboutsummaryrefslogtreecommitdiff
path: root/challenge-243
diff options
context:
space:
mode:
authorLakpa Tashi Bhutia <lakpatashi@users.noreply.github.com>2023-11-25 21:02:55 +0530
committerGitHub <noreply@github.com>2023-11-25 21:02:55 +0530
commit6db863c3ee8cb8a3315eeae5fde99af83385aefc (patch)
tree761f0c9b8aef13375cca819d8deed4a70fff8c7e /challenge-243
parent9c96baeeda85997b321a4d4fbebd5fd51bffb729 (diff)
parent9a1dd9390973363a40ccda4a6d03f9f61a0ae386 (diff)
downloadperlweeklychallenge-club-6db863c3ee8cb8a3315eeae5fde99af83385aefc.tar.gz
perlweeklychallenge-club-6db863c3ee8cb8a3315eeae5fde99af83385aefc.tar.bz2
perlweeklychallenge-club-6db863c3ee8cb8a3315eeae5fde99af83385aefc.zip
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-243')
-rw-r--r--challenge-243/adam-russell/.gitignore3
-rw-r--r--challenge-243/adam-russell/blog.txt1
-rw-r--r--challenge-243/adam-russell/blog1.txt1
-rw-r--r--challenge-243/adam-russell/javascript/ch-1.js19
-rw-r--r--challenge-243/adam-russell/javascript/ch-2.js18
-rw-r--r--challenge-243/adam-russell/perl/ch-1.pl27
-rw-r--r--challenge-243/adam-russell/perl/ch-2.pl28
-rw-r--r--challenge-243/adam-russell/prolog/ch-1.p8
-rw-r--r--challenge-243/adam-russell/prolog/ch-2.p11
-rw-r--r--challenge-243/adam-russell/r/ch-1.r25
-rw-r--r--challenge-243/adam-russell/r/ch-2.r23
-rw-r--r--challenge-243/barroff/julia/ch-1.jl12
-rw-r--r--challenge-243/barroff/raku/ch-1.p620
-rw-r--r--challenge-243/barroff/raku/ch-2.p620
-rw-r--r--challenge-243/bruce-gray/javascript/ch-1.js145
-rw-r--r--challenge-243/bruce-gray/javascript/ch-2.js54
-rw-r--r--challenge-243/bruce-gray/raku/ch-1.raku16
-rw-r--r--challenge-243/bruce-gray/raku/ch-2.raku32
-rw-r--r--challenge-243/cheok-yin-fung/perl/ch-1.pl19
-rw-r--r--challenge-243/cheok-yin-fung/perl/ch-2.pl19
-rw-r--r--challenge-243/massa/raku/ch-1.raku66
-rw-r--r--challenge-243/massa/raku/ch-2.raku67
-rw-r--r--challenge-243/matthias-muth/README.md318
-rw-r--r--challenge-243/matthias-muth/blog.txt1
-rw-r--r--challenge-243/matthias-muth/perl/TestExtractor.pm281
-rwxr-xr-xchallenge-243/matthias-muth/perl/ch-1.pl106
-rwxr-xr-xchallenge-243/matthias-muth/perl/ch-2.pl96
-rw-r--r--challenge-243/matthias-muth/perl/challenge-243.txt56
-rw-r--r--challenge-243/roger-bell-west/blog.txt1
-rw-r--r--challenge-243/sgreen/README.md4
-rw-r--r--challenge-243/sgreen/blog.txt1
-rwxr-xr-xchallenge-243/sgreen/perl/ch-1.pl20
-rwxr-xr-xchallenge-243/sgreen/perl/ch-2.pl20
-rwxr-xr-xchallenge-243/sgreen/python/ch-1.py18
-rwxr-xr-xchallenge-243/sgreen/python/ch-2.py15
-rw-r--r--challenge-243/solathian/perl/ch-1.pl30
-rw-r--r--challenge-243/solathian/perl/ch-2.pl28
-rw-r--r--challenge-243/vinod-k/perl/ch-1.pl26
-rw-r--r--challenge-243/wambash/raku/ch-1.raku19
-rw-r--r--challenge-243/wambash/raku/ch-2.raku18
-rwxr-xr-xchallenge-243/wanderdoc/perl/ch-1.pl43
-rwxr-xr-xchallenge-243/wanderdoc/perl/ch-2.pl44
42 files changed, 1697 insertions, 82 deletions
diff --git a/challenge-243/adam-russell/.gitignore b/challenge-243/adam-russell/.gitignore
new file mode 100644
index 0000000000..d4e9a94d5e
--- /dev/null
+++ b/challenge-243/adam-russell/.gitignore
@@ -0,0 +1,3 @@
+*.bbprojectd
+.RData
+.Rhistory
diff --git a/challenge-243/adam-russell/blog.txt b/challenge-243/adam-russell/blog.txt
new file mode 100644
index 0000000000..b0e8e4e7a8
--- /dev/null
+++ b/challenge-243/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://rabbitfarm.com/cgi-bin/blosxom/perl/2023/11/19 \ No newline at end of file
diff --git a/challenge-243/adam-russell/blog1.txt b/challenge-243/adam-russell/blog1.txt
new file mode 100644
index 0000000000..dd30862401
--- /dev/null
+++ b/challenge-243/adam-russell/blog1.txt
@@ -0,0 +1 @@
+http://rabbitfarm.com/cgi-bin/blosxom/prolog/2023/11/19 \ No newline at end of file
diff --git a/challenge-243/adam-russell/javascript/ch-1.js b/challenge-243/adam-russell/javascript/ch-1.js
new file mode 100644
index 0000000000..929338a160
--- /dev/null
+++ b/challenge-243/adam-russell/javascript/ch-1.js
@@ -0,0 +1,19 @@
+class Ch1{
+ reversePairs(integers){
+ let r = [];
+ for(let i = 0; i < integers.length; i++){
+ for(let j = i + 1; j < integers.length; j++){
+ if(integers[i] > integers[j] + integers[j])
+ r.push([i, j]);
+ }
+ }
+ return r.length;
+ }
+}
+let ch1 = new Ch1();
+console.log(
+ ch1.reversePairs([1, 3, 2, 3, 1])
+);
+console.log(
+ ch1.reversePairs([2, 4, 3, 5, 1])
+); \ No newline at end of file
diff --git a/challenge-243/adam-russell/javascript/ch-2.js b/challenge-243/adam-russell/javascript/ch-2.js
new file mode 100644
index 0000000000..ef2fdcd56f
--- /dev/null
+++ b/challenge-243/adam-russell/javascript/ch-2.js
@@ -0,0 +1,18 @@
+class Ch2{
+ floorSum(integers){
+ let floorSum = 0;
+ integers.forEach(function(x){
+ integers.forEach(function(y){
+ floorSum += Math.floor(x / y)
+ });
+ });
+ return floorSum;
+ }
+}
+let ch2 = new Ch2();
+console.log(
+ ch2.floorSum([2, 5, 9])
+);
+console.log(
+ ch2.floorSum([7, 7, 7, 7, 7, 7, 7])
+); \ No newline at end of file
diff --git a/challenge-243/adam-russell/perl/ch-1.pl b/challenge-243/adam-russell/perl/ch-1.pl
new file mode 100644
index 0000000000..9f2093359a
--- /dev/null
+++ b/challenge-243/adam-russell/perl/ch-1.pl
@@ -0,0 +1,27 @@
+use v5.38;
+##
+# You are given an array of integers. Write a script to return the
+# number of reverse pairs in the given array. A reverse pair is:
+# a pair (i, j)
+# where:
+# a) 0 <= i < j < nums.length
+# and
+# b) nums[i] > 2 * nums[j].
+##
+sub reverse_pairs{
+ my @integers = @_;
+ my @reverse_pairs;
+ do{
+ my $i = $_;
+ do{
+ my $j = $_;
+ push @reverse_pairs, [$i, $j] if $integers[$i] > $integers[$j] + $integers[$j];
+ } for $i + 1 .. @integers - 1;
+ } for 0 .. @integers - 1;
+ return 0 + @reverse_pairs;
+}
+
+MAIN:{
+ say reverse_pairs 1, 3, 2, 3, 1;
+ say reverse_pairs 2, 4, 3, 5, 1;
+} \ No newline at end of file
diff --git a/challenge-243/adam-russell/perl/ch-2.pl b/challenge-243/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..797eb150c3
--- /dev/null
+++ b/challenge-243/adam-russell/perl/ch-2.pl
@@ -0,0 +1,28 @@
+use v5.38;
+##
+# You are given an array of positive integers (>=1). Write a script to
+# return the sum of
+# floor(nums[i] / nums[j])
+# where
+# 0 <= i,j < nums.length.
+# We define the floor() function as returning the integer part of the
+# division.
+##
+use POSIX;
+sub floor_sum{
+ my @integers = @_;
+ my $floor_sum;
+ do{
+ my $i = $_;
+ do{
+ my $j = $_;
+ $floor_sum += floor($integers[$i] / $integers[$j]);
+ } for 0 .. @integers - 1;
+ } for 0 .. @integers - 1;
+ return $floor_sum;
+}
+
+MAIN:{
+ say floor_sum 2, 5, 9;
+ say floor_sum 7, 7, 7, 7, 7, 7, 7;
+}
diff --git a/challenge-243/adam-russell/prolog/ch-1.p b/challenge-243/adam-russell/prolog/ch-1.p
new file mode 100644
index 0000000000..fce375eb9b
--- /dev/null
+++ b/challenge-243/adam-russell/prolog/ch-1.p
@@ -0,0 +1,8 @@
+reverse_pair(X, Y, Z):-
+ (X =\= Y, X > Y + Y, Z = 1, !); Z = 0.
+reverse_pairs([], 0).
+reverse_pairs([H|T], ReversePairs):-
+ reverse_pairs(T, R),
+ maplist(reverse_pair(H), T, RP),
+ sum_list(RP, Sum),
+ ReversePairs is R + Sum. \ No newline at end of file
diff --git a/challenge-243/adam-russell/prolog/ch-2.p b/challenge-243/adam-russell/prolog/ch-2.p
new file mode 100644
index 0000000000..502d0239de
--- /dev/null
+++ b/challenge-243/adam-russell/prolog/ch-2.p
@@ -0,0 +1,11 @@
+floor_sum_pair(X, Y, Z):-
+ Z is floor(X / Y).
+
+floor_sum(Integers, FloorSum):-
+ floor_sum(Integers, Integers, FloorSum).
+floor_sum([], _, 0).
+floor_sum([H|T], L, FloorSum):-
+ floor_sum(T, L, F),
+ maplist(floor_sum_pair(H), L, FS),
+ sum_list(FS, Sum),
+ FloorSum is F + Sum. \ No newline at end of file
diff --git a/challenge-243/adam-russell/r/ch-1.r b/challenge-243/adam-russell/r/ch-1.r
new file mode 100644
index 0000000000..f89c96d0da
--- /dev/null
+++ b/challenge-243/adam-russell/r/ch-1.r
@@ -0,0 +1,25 @@
+ch_1 <- function(){
+ structure(list(), class = "ch_1")
+}
+
+reverse_pairs <- function(self, l){
+ UseMethod("reverse_pairs", self)
+}
+
+reverse_pairs.ch_1 <- function(self, integers) {
+ r <- list()
+ for (i in 1:(length(integers) - 1)) {
+ for (j in (i + 1):length(integers)) {
+ if (integers[i] > integers[j] + integers[j]) {
+ r <- c(r, list(c(i, j)))
+ }
+ }
+ }
+ return(length(r))
+}
+
+ch_1 <- ch_1()
+number_reverse_pairs <- reverse_pairs(ch_1, c(1, 3, 2, 3, 1))
+print(number_reverse_pairs)
+number_reverse_pairs <- reverse_pairs(ch_1, c(2, 4, 3, 5, 1))
+print(number_reverse_pairs) \ No newline at end of file
diff --git a/challenge-243/adam-russell/r/ch-2.r b/challenge-243/adam-russell/r/ch-2.r
new file mode 100644
index 0000000000..bffca25287
--- /dev/null
+++ b/challenge-243/adam-russell/r/ch-2.r
@@ -0,0 +1,23 @@
+ch_2 <- function(){
+ structure(list(), class = "ch_2")
+}
+
+floor_sum <- function(self, l){
+ UseMethod("floor_sum", self)
+}
+
+floor_sum <- function(self, integers) {
+ floor_sum <- 0
+ for (x in integers) {
+ for (y in integers) {
+ floor_sum <- floor_sum + floor(x / y)
+ }
+ }
+ return(floor_sum)
+}
+
+ch_2 <- ch_2()
+floor_summed <- floor_sum(ch_1, c(2, 5, 9))
+print(floor_summed)
+floor_summed <- floor_sum(ch_1, c(7, 7, 7, 7, 7, 7, 7))
+print(floor_summed) \ No newline at end of file
diff --git a/challenge-243/barroff/julia/ch-1.jl b/challenge-243/barroff/julia/ch-1.jl
new file mode 100644
index 0000000000..3e23ec0339
--- /dev/null
+++ b/challenge-243/barroff/julia/ch-1.jl
@@ -0,0 +1,12 @@
+#!/usr/bin/env julia
+
+using Test: @test, @testset
+
+function reverse_pairs(nums::Vector{T}) where {T<:Integer}
+ sum(map(x -> length(filter(y -> x[2] > 2 * y, nums[x[1]:end])), enumerate(nums)))
+end
+
+@testset "reverse pairs" begin
+ @test reverse_pairs([1, 3, 2, 3, 1]) == 2
+ @test reverse_pairs([2, 4, 3, 5, 1]) == 3
+end
diff --git a/challenge-243/barroff/raku/ch-1.p6 b/challenge-243/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..79458c5f4b
--- /dev/null
+++ b/challenge-243/barroff/raku/ch-1.p6
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+sub reverse-pairs(@nums --> Int) {
+ grep({ $_[0] > 2 * $_[1] }, combinations(@nums, 2)).elems;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 2;
+
+ is reverse-pairs([1, 3, 2, 3, 1]), 2, 'Works for (1, 3, 2, 3, 1)';
+ is reverse-pairs([2, 4, 3, 5, 1]), 3, 'Works for (2, 4, 3, 5, 1)';
+}
+
+#| Take user provided list like 1 1 2 2 2 3
+multi sub MAIN(Int @ints) {
+ my Int @nums = @ints;
+ say reverse-pairs(@nums);
+}
diff --git a/challenge-243/barroff/raku/ch-2.p6 b/challenge-243/barroff/raku/ch-2.p6
new file mode 100644
index 0000000000..4d313dbd8f
--- /dev/null
+++ b/challenge-243/barroff/raku/ch-2.p6
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+sub floor-sum(@nums where all(@nums) ≥ 1 --> Int) {
+ sum(map({ $_[0] div $_[1] + $_[1] div $_[0] }, combinations(@nums, 2))) + @nums.elems;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 2;
+
+ is floor-sum([2, 5, 9]), 10, 'Works for (2, 5, 9)';
+ is floor-sum([7, 7, 7, 7, 7, 7, 7]), 49, 'Works for (7, 7, 7, 7, 7, 7, 7)';
+}
+
+#| Take user provided list like 1 1 2 2 2 3
+multi sub MAIN(Int @ints) {
+ my Int @nums = @ints;
+ say floor-sum(@nums);
+}
diff --git a/challenge-243/bruce-gray/javascript/ch-1.js b/challenge-243/bruce-gray/javascript/ch-1.js
new file mode 100644
index 0000000000..3d798122d9
--- /dev/null
+++ b/challenge-243/bruce-gray/javascript/ch-1.js
@@ -0,0 +1,145 @@
+#!/usr/bin/env node
+'use strict';
+
+// Procedural, with manual accumulator
+function task1a ( ns ) {
+ let ret = 0;
+
+ for ( const [i, left] of ns.entries() )
+ for ( const right of ns.slice(i+1) )
+ if ( left > (right * 2) )
+ ret++;
+
+ return ret;
+}
+
+// task1a, with inner loop (for&if) refactored to functional (filter&length).
+function task1b ( ns ) {
+ let ret = 0;
+ for ( const [i, left] of ns.entries() ) {
+ ret += ns.slice(i+1).filter((right) => left > (right * 2)).length;
+ }
+ return ret;
+}
+
+// task1b, with the filter expression extracted to a named local function.
+function task1c ( ns ) {
+ let ret = 0;
+ for ( const [i, left] of ns.entries() ) {
+
+ const is_reverse_pair = (right) => left > (right * 2);
+
+ ret += ns.slice(i+1)
+ .filter(is_reverse_pair)
+ .length;
+ }
+ return ret;
+}
+
+// task1c, with the outer loop refactored to .map(), and accumulator embedded in a .reduce().
+function task1d ( ns ) {
+ const add = (a, b) => a + b;
+
+ const count_of_reverse_pairs_with_left = ([i, left]) => {
+
+ const is_reverse_pair = (right) => left > (right * 2);
+
+ return ns.slice(i+1)
+ .filter(is_reverse_pair)
+ .length;
+ }
+
+ return [...ns.entries()].map( count_of_reverse_pairs_with_left ).reduce(add, 0);
+}
+
+// Cannot use a faster .reduce directly on Iterator; experimental feature provided by Node.
+function task1e ( ns ) {
+ const count_of_reverse_pairs_with_this_element = (accumumlator, [i, left]) => {
+ const is_reverse_pair = (right) => left > (right * 2);
+
+ const count = ns.slice(i+1)
+ .filter(is_reverse_pair)
+ .length;
+
+ return accumumlator + count;
+ }
+
+ return [ ...ns.entries() ].reduce(count_of_reverse_pairs_with_this_element, 0);
+}
+
+// task1d with map+reduce merged
+function task1f ( ns ) {
+ // const add = (a, b) => a + b;
+
+ const reverse_pairs = ([i, left]) => {
+
+ const is_reverse_pair = (right) => left > (right * 2);
+
+ return ns.slice(i+1)
+ .filter(is_reverse_pair)
+ .length;
+ }
+ const sum_reverse_pairs = (a, e) => a + reverse_pairs(e);
+
+ return [ ...ns.entries() ].reduce(sum_reverse_pairs, 0);
+}
+
+// pre-doubled once into a parallel `two_n` array, to reduce recalculations.
+function task1g ( ns ) {
+ const two_n = ns.map( n => 2*n );
+
+ const reverse_pairs = ([i, left]) => {
+
+ const is_reverse_pair = (right) => left > right;
+
+ return two_n.slice(i+1)
+ .filter(is_reverse_pair)
+ .length;
+ }
+ const sum_reverse_pairs = (a, e) => a + reverse_pairs(e);
+
+ return [ ...ns.entries() ].reduce(sum_reverse_pairs, 0);
+}
+
+// Extracted "combinations"
+function task1h ( ns ) {
+ const combinations_2 = (arr, func) => {
+ arr.forEach( (left,i) => {
+ arr.slice(i+1).map( (right) => func(left, right) );
+ });
+ }
+
+ let count = 0;
+ const count_wanted = (L,R) => { if ( L > (R * 2) ) count++ };
+ combinations_2(ns, count_wanted);
+ return count;
+}
+
+const subs = [
+ [ 'task1a', task1a ],
+ [ 'task1b', task1b ],
+ [ 'task1c', task1c ],
+ [ 'task1d', task1d ],
+ [ 'task1e', task1e ],
+ [ 'task1f', task1f ],
+ [ 'task1g', task1g ],
+ [ 'task1h', task1h ],
+];
+const tests = [
+ [ 2, [1, 3, 2, 3, 1], 'Example 1 from task' ],
+ [ 3, [2, 4, 3, 5, 1], 'Example 2 from task' ],
+ [ 0, [] , 'Null array' ],
+];
+let test_number = 0;
+function is ( got, expected, desc ) {
+ test_number++;
+ const ok_msg = (got === expected) ? "ok" : "not ok";
+ const description = (typeof desc !== 'undefined') ? ` - ${desc}` : '';
+ console.log(`${ok_msg} ${test_number}${description}`);
+}
+for ( const [ sub_name, task1_coderef ] of subs ) {
+ for ( const [ expected, input, test_name ] of tests ) {
+ const got = task1_coderef(input);
+ is( got, expected, `${sub_name}: ${test_name}`);
+ }
+}
diff --git a/challenge-243/bruce-gray/javascript/ch-2.js b/challenge-243/bruce-gray/javascript/ch-2.js
new file mode 100644
index 0000000000..c5664a5c35
--- /dev/null
+++ b/challenge-243/bruce-gray/javascript/ch-2.js
@@ -0,0 +1,54 @@
+// Procedural
+function task2a ( ns ) {
+ let ret = 0;
+ for ( const x of ns ) {
+ for ( const y of ns ) {
+ ret += Math.floor( x / y );
+ }
+ }
+ return ret;
+}
+
+// Functional, both using extracted code for Cartesian product.
+const cartesian =
+ (...top_level_arrays) => top_level_arrays.reduce(
+ (accum, an_array) => accum.flatMap(
+ (element1) => an_array.map(
+ (element2) => [element1, element2].flat()
+)));
+
+// .map(), then sum via .reduce .
+function task2b (ns) {
+ return cartesian(ns, ns)
+ .map(([x,y]) => Math.floor(x/y))
+ .reduce(((a,b) => a+b),0);
+}
+
+// Do the summing *and* mapping during the .reduce .
+const task2c = (ns) => cartesian(ns, ns).reduce(((a,[x,y]) => a+Math.floor(x/y)),0);
+
+
+
+let test_number = 0;
+function is ( got, expected, desc ) {
+ test_number++;
+ const ok_msg = (got === expected) ? "ok" : "not ok";
+ const description = (typeof desc !== 'undefined') ? ` - ${desc}` : '';
+ console.log(`${ok_msg} ${test_number}${description}`);
+}
+const subs = [
+ [ 'task2a', task2a ],
+ [ 'task2b', task2b ],
+ [ 'task2c', task2c ],
+];
+const tests = [
+ [ 10, [2, 5, 9] , 'Example 1 from task'],
+ [ 49, [7,7,7,7,7,7,7], 'Example 2 from task'],
+ [ 10, [2, 5, 9] , 'Null array'],
+];
+for ( const [ sub_name, task2_coderef ] of subs ) {
+ for ( const [ expected, input, test_name ] of tests ) {
+ const got = task2_coderef(input);
+ is( got, expected, `${sub_name}: ${test_name}`);
+ }
+}
diff --git a/challenge-243/bruce-gray/raku/ch-1.raku b/challenge-243/bruce-gray/raku/ch-1.raku
new file mode 100644
index 0000000000..fee01833c8
--- /dev/null
+++ b/challenge-243/bruce-gray/raku/ch-1.raku
@@ -0,0 +1,16 @@
+sub task1 ( @ns ) {
+ sub is_reverse_pair ( [$left, $right] ) { $left > ($right * 2) }
+
+ return +grep &is_reverse_pair,
+ combinations(@ns, 2);
+}
+
+
+constant @tests =
+ ( 2, (1, 3, 2, 3, 1) ),
+ ( 3, (2, 4, 3, 5, 1) ),
+;
+use Test; plan +@tests;
+for @tests -> ($expected, @ns) {
+ is task1(@ns), $expected;
+}
diff --git a/challenge-243/bruce-gray/raku/ch-2.raku b/challenge-243/bruce-gray/raku/ch-2.raku
new file mode 100644
index 0000000000..b7d2751cab
--- /dev/null
+++ b/challenge-243/bruce-gray/raku/ch-2.raku
@@ -0,0 +1,32 @@
+# Note that `div` can take the place of `floor after division`
+# only because the task specifies integers.
+# https://docs.raku.org/language/operators#infix_div
+# https://docs.raku.org/language/operators#infix_X
+# https://docs.raku.org/language/operators#Cross_metaoperators
+sub task2_simple ( @ns ) {
+ return sum( @ns Xdiv @ns );
+}
+
+constant &task2_inscrutable = { [+] [Xdiv] @^ns xx 2 };
+
+# For 10_000 element array (100 duplicates of a line of 100 random 2-digit numbers):
+# 3 seconds for task2_faster, vs 42 seconds for &task2_simple.
+sub task2_faster ( @ns ) {
+ my @p = @ns.Bag;
+
+ return sum map { [*] |$_».value, |[div] $_».key }, ( @p X @p );
+}
+
+
+
+constant @subs = :&task2_simple, :&task2_inscrutable, :&task2_faster;
+constant @tests =
+ ( 10, (2, 5, 9) ),
+ ( 49, (7, 7, 7, 7, 7, 7, 7) ),
+;
+use Test; plan +@subs * +@tests;
+for @subs -> ( :key($sub_name), :value($task2) ) {
+ for @tests.kv -> $i, ($expected, @ns) {
+ is $task2.(@ns), $expected, "$sub_name.fmt('%-18s'): Example {$i+1}";
+ }
+}
diff --git a/challenge-243/cheok-yin-fung/perl/ch-1.pl b/challenge-243/cheok-yin-fung/perl/ch-1.pl
new file mode 100644
index 0000000000..bd99fce9c2
--- /dev/null
+++ b/challenge-243/cheok-yin-fung/perl/ch-1.pl
@@ -0,0 +1,19 @@
+# The Weekly Challenge 243
+# Task 1 Reverse Pairs
+use v5.30.0;
+use warnings;
+
+sub rp {
+ my @nums = @_;
+ my $ans = 0;
+ for my $j (reverse 1..$#nums) {
+ for my $i (0..$j-1) {
+ $ans++ if $nums[$i] > 2*$nums[$j];
+ }
+ }
+ return $ans;
+}
+
+use Test::More tests=>2;
+ok rp(1,3,2,3,1) == 2;
+ok rp(2,4,3,5,1) == 3;
diff --git a/challenge-243/cheok-yin-fung/perl/ch-2.pl b/challenge-243/cheok-yin-fung/perl/ch-2.pl
new file mode 100644
index 0000000000..d7148a55f2
--- /dev/null
+++ b/challenge-243/cheok-yin-fung/perl/ch-2.pl
@@ -0,0 +1,19 @@
+# The Weekly Challenge 243
+# Task 2 Floor Sum
+use v5.30.0;
+use warnings;
+
+sub fs {
+ my @nums = @_;
+ my $sum = 0;
+ for my $m (@nums) {
+ for my $n (@nums) {
+ $sum += int($m/$n);
+ }
+ }
+ return $sum;
+}
+
+use Test::More tests=>2;
+ok fs(2,5,9) == 10;
+ok fs(7,7,7,7,7,7,7) == 49;
diff --git a/challenge-243/massa/raku/ch-1.raku b/challenge-243/massa/raku/ch-1.raku
new file mode 100644
index 0000000000..92be046bab
--- /dev/null
+++ b/challenge-243/massa/raku/ch-1.raku
@@ -0,0 +1,66 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 1: Reverse Pairs
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+You are given two arrays of integers.
+
+Write a script to return the number of reverse pairs in the given array.
+
+A reverse pair is a pair (i, j) where: a) 0 <= i < j < nums.length and b)
+nums[i] > 2 * nums[j].
+
+=head3 Example 1:
+
+ Input: @nums = (1, 3, 2, 3, 1)
+ Output: 2
+
+ (1, 4) => nums[1] = 3, nums[4] = 1, 3 > 2 * 1
+ (3, 4) => nums[3] = 3, nums[4] = 1, 3 > 2 * 1
+
+=head3 Example 2:
+
+ Input: @nums = (2, 4, 3, 5, 1)
+ Output: 3
+
+ (1, 4) => nums[1] = 4, nums[4] = 1, 4 > 2 * 1
+ (2, 4) => nums[2] = 3, nums[4] = 1, 3 > 2 * 1
+ (3, 4) => nums[3] = 5, nums[4] = 1, 5 > 2 * 1
+
+=SOLUTION
+
+=end pod
+
+# always use the latest version of Raku
+use v6.*;
+
+sub SOLUTION(@m) {
+ + @m.pairs.combinations(2).grep({.[0].value > 2 * .[1].value})».key
+}
+
+multi MAIN (Bool :$test!) {
+ use Test;
+
+ my @tests =
+ %{ input => (1, 3, 2, 3, 1),
+ output => (2,) },
+ %{ input => (2, 4, 3, 5, 1),
+ output => (3,) },
+ ;
+
+ .<input>.&SOLUTION.deepmap({$_}).&is-deeply: .<output>, .<text> for @tests
+} # end of multi MAIN (Bool :$test!)
+
+
diff --git a/challenge-243/massa/raku/ch-2.raku b/challenge-243/massa/raku/ch-2.raku
new file mode 100644
index 0000000000..2899677d8b
--- /dev/null
+++ b/challenge-243/massa/raku/ch-2.raku
@@ -0,0 +1,67 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 2: Floor Sum
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+You are given an array of positive integers (>=1).
+
+Write a script to return the sum of floor(nums[i] / nums[j]) where 0 <= i,j <
+nums.length. The floor() function returns the integer part of the division.
+
+=head3 Example 1:
+
+ Input: @nums = (2, 5, 9)
+ Output: 10
+
+ floor(2 / 5) = 0
+ floor(2 / 9) = 0
+ floor(5 / 9) = 0
+ floor(2 / 2) = 1
+ floor(5 / 5) = 1
+ floor(9 / 9) = 1
+ floor(5 / 2) = 2
+ floor(9 / 2) = 4
+ floor(9 / 5) = 1
+
+=head3 Example 2:
+
+ Input: @nums = (7, 7, 7, 7,