From 87b63d3827da9980b2a3fb29f28b477a62b67cbd Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Mon, 1 Sep 2025 14:43:06 +0100 Subject: - Added solutions by Andreas Mahnke. - Added solutions by Niels van Dijke. --- challenge-337/perlboy1967/perl/ch-1.pl | 34 ++++++++++++++++++++++ challenge-337/perlboy1967/perl/ch-2.pl | 47 +++++++++++++++++++++++++++++++ challenge-337/perlboy1967/perl/ch1.pl | 34 ---------------------- challenge-337/perlboy1967/perl/ch2.pl | 47 ------------------------------- stats/pwc-current.json | 32 ++++++++++++++++++++- stats/pwc-language-breakdown-2019.json | 2 +- stats/pwc-language-breakdown-2020.json | 2 +- stats/pwc-language-breakdown-2021.json | 2 +- stats/pwc-language-breakdown-2022.json | 2 +- stats/pwc-language-breakdown-2023.json | 2 +- stats/pwc-language-breakdown-2024.json | 2 +- stats/pwc-language-breakdown-2025.json | 6 ++-- stats/pwc-language-breakdown-summary.json | 4 +-- stats/pwc-leaders.json | 6 ++-- stats/pwc-summary-1-30.json | 4 +-- stats/pwc-summary-121-150.json | 2 +- stats/pwc-summary-151-180.json | 2 +- stats/pwc-summary-181-210.json | 4 +-- stats/pwc-summary-211-240.json | 2 +- stats/pwc-summary-241-270.json | 2 +- stats/pwc-summary-271-300.json | 2 +- stats/pwc-summary-301-330.json | 2 +- stats/pwc-summary-31-60.json | 2 +- stats/pwc-summary-61-90.json | 2 +- stats/pwc-summary-91-120.json | 2 +- stats/pwc-summary.json | 6 ++-- stats/pwc-yearly-language-summary.json | 6 ++-- 27 files changed, 145 insertions(+), 115 deletions(-) create mode 100755 challenge-337/perlboy1967/perl/ch-1.pl create mode 100755 challenge-337/perlboy1967/perl/ch-2.pl delete mode 100755 challenge-337/perlboy1967/perl/ch1.pl delete mode 100755 challenge-337/perlboy1967/perl/ch2.pl diff --git a/challenge-337/perlboy1967/perl/ch-1.pl b/challenge-337/perlboy1967/perl/ch-1.pl new file mode 100755 index 0000000000..24b46dd586 --- /dev/null +++ b/challenge-337/perlboy1967/perl/ch-1.pl @@ -0,0 +1,34 @@ +#!/bin/perl + +=pod + +L + +Author: Niels 'PerlBoy' van Dijke + +Task 1: Smaller Than Current +Submitted by: Mohammad Sajid Anwar + +You are given an array of numbers, @num1. + +Write a script to return an array, @num2, where $num2[i] is the count of +all numbers less than or equal to $num1[i]. + +=cut + +use Test2::V0 qw(-no_srand); +use exact 'v5.32', -signatures; + +sub smallerThanCurrent (@ints) { + my %cache; + map { my $i = $_; $cache{$i} //= scalar(grep { $_ < $i } @ints); $cache{$i} } @ints; +} + +is([smallerThanCurrent(6,5,4,8)],[2,1,0,3],'Example 1'); +is([smallerThanCurrent(7,7,7,7)],[0,0,0,0],'Example 2'); +is([smallerThanCurrent(5,4,3,2,1)],[4,3,2,1,0],'Example 3'); +is([smallerThanCurrent(-1,0,3,-2,1)],[1,2,4,0,3],'Example 4'); +is([smallerThanCurrent(0,2,2,4,0)],[0,2,2,4,0],'Example 5'); +is([smallerThanCurrent((1) x 10_000)],[(0) x 10_000],'Own example'); + +done_testing; diff --git a/challenge-337/perlboy1967/perl/ch-2.pl b/challenge-337/perlboy1967/perl/ch-2.pl new file mode 100755 index 0000000000..d514247f4f --- /dev/null +++ b/challenge-337/perlboy1967/perl/ch-2.pl @@ -0,0 +1,47 @@ +#!/bin/perl + +=pod + +L + +Author: Niels 'PerlBoy' van Dijke + +Task 2: Odd Matrix +Submitted by: Mohammad Sajid Anwar + +You are given row and col, also a list of positions in the matrix. + +Write a script to perform action on each location (0-indexed) as provided in +the list and find out the total odd valued cells. + +For each location (r, c), do both of the following: + +a) Increment by 1 all the cells on row r. +b) Increment by 1 all the cells on column c. + +=cut + +use Test2::V0 qw(-no_srand); +use exact 'v5.32', -signatures; + +use List::Util qw(sum0); + +sub oddMatrix ($row,$col,@locations) { + my @m = map { [(0) x $col] } (0 .. --$row); + $col--; + + for (@locations) { + my ($r,$c) = @$_; + $m[$r][$_]++ for (0 .. $col); + $m[$_][$c]++ for (0 .. $row); + } + + sum0 map { scalar grep { $_ % 2 } @$_ } @m; +} + +is(oddMatrix(2,3,[0,1],[1,1]),6,'Example 1'); +is(oddMatrix(2,2,[1,1],[0,0]),0,'Example 2'); +is(oddMatrix(3,3,[0,0],[1,2],[2,1]),0,'Example 3'); +is(oddMatrix(1,5,[0,2],[0,4]),2,'Example 4'); + +done_testing; diff --git a/challenge-337/perlboy1967/perl/ch1.pl b/challenge-337/perlboy1967/perl/ch1.pl deleted file mode 100755 index 24b46dd586..0000000000 --- a/challenge-337/perlboy1967/perl/ch1.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/perl - -=pod - -L - -Author: Niels 'PerlBoy' van Dijke - -Task 1: Smaller Than Current -Submitted by: Mohammad Sajid Anwar - -You are given an array of numbers, @num1. - -Write a script to return an array, @num2, where $num2[i] is the count of -all numbers less than or equal to $num1[i]. - -=cut - -use Test2::V0 qw(-no_srand); -use exact 'v5.32', -signatures; - -sub smallerThanCurrent (@ints) { - my %cache; - map { my $i = $_; $cache{$i} //= scalar(grep { $_ < $i } @ints); $cache{$i} } @ints; -} - -is([smallerThanCurrent(6,5,4,8)],[2,1,0,3],'Example 1'); -is([smallerThanCurrent(7,7,7,7)],[0,0,0,0],'Example 2'); -is([smallerThanCurrent(5,4,3,2,1)],[4,3,2,1,0],'Example 3'); -is([smallerThanCurrent(-1,0,3,-2,1)],[1,2,4,0,3],'Example 4'); -is([smallerThanCurrent(0,2,2,4,0)],[0,2,2,4,0],'Example 5'); -is([smallerThanCurrent((1) x 10_000)],[(0) x 10_000],'Own example'); - -done_testing; diff --git a/challenge-337/perlboy1967/perl/ch2.pl b/challenge-337/perlboy1967/perl/ch2.pl deleted file mode 100755 index d514247f4f..0000000000 --- a/challenge-337/perlboy1967/perl/ch2.pl +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/perl - -=pod - -L - -Author: Niels 'PerlBoy' van Dijke - -Task 2: Odd Matrix -Submitted by: Mohammad Sajid Anwar - -You are given row and col, also a list of positions in the matrix. - -Write a script to perform action on each location (0-indexed) as provided in -the list and find out the total odd valued cells. - -For each location (r, c), do both of the following: - -a) Increment by 1 all the cells on row r. -b) Increment by 1 all the cells on column c. - -=cut - -use Test2::V0 qw(-no_srand); -use exact 'v5.32', -signatures; - -use List::Util qw(sum0); - -sub oddMatrix ($row,$col,@locations) { - my @m = map { [(0) x $col] } (0 .. --$row); - $col--; - - for (@locations) { - my ($r,$c) = @$_; - $m[$r][$_]++ for (0 .. $col); - $m[$_][$c]++ for (0 .. $row); - } - - sum0 map { scalar grep { $_ % 2 } @$_ } @m; -} - -is(oddMatrix(2,3,[0,1],[1,1]),6,'Example 1'); -is(oddMatrix(2,2,[1,1],[0,0]),0,'Example 2'); -is(oddMatrix(3,3,[0,0],[1,2],[2,1]),0,'Example 3'); -is(oddMatrix(1,5,[0,2],[0,4]),2,'Example 4'); - -done_testing; diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 7b32635bd5..98353ba96f 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -4,6 +4,16 @@ }, "drilldown" : { "series" : [ + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Andreas Mahnke", + "name" : "Andreas Mahnke" + }, { "data" : [ [ @@ -24,6 +34,16 @@ "id" : "Mark Anderson", "name" : "Mark Anderson" }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, { "data" : [ [ @@ -56,6 +76,11 @@ { "colorByPoint" : 1, "data" : [ + { + "drilldown" : "Andreas Mahnke", + "name" : "Andreas Mahnke", + "y" : 2 + }, { "drilldown" : "Feng Chang", "name" : "Feng Chang", @@ -66,6 +91,11 @@ "name" : "Mark Anderson", "y" : 2 }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, { "drilldown" : "W. Luis Mochan", "name" : "W. Luis Mochan", @@ -76,7 +106,7 @@ } ], "subtitle" : { - "text" : "[Champions: 3] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 5] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge - 337" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index fd97c57cb9..963acd2f18 100644 --- a/stats/pwc-language-breakdown-2019.json +++ b/stats/pwc-language-breakdown-2019.json @@ -970,7 +970,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index 03fc7f5ad8..461253099b 100644 --- a/stats/pwc-language-breakdown-2020.json +++ b/stats/pwc-language-breakdown-2020.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index b5c52d7316..a02dec5f37 100644 --- a/stats/pwc-language-breakdown-2021.json +++ b/stats/pwc-language-breakdown-2021.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 7cdec067cf..1a36567b34 100644 --- a/stats/pwc-language-breakdown-2022.json +++ b/stats/pwc-language-breakdown-2022.json @@ -1223,7 +1223,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index 641d3a7c3e..9ff5674fbd 100644 --- a/stats/pwc-language-breakdown-2023.json +++ b/stats/pwc-language-breakdown-2023.json @@ -1200,7 +1200,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index c1ce6fb027..ca0bcf7da2 100644 --- a/stats/pwc-language-breakdown-2024.json +++ b/stats/pwc-language-breakdown-2024.json @@ -1246,7 +1246,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index f6b273326f..86d33ea16b 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 2 + 6 ], [ "Raku", @@ -655,7 +655,7 @@ { "drilldown" : "337", "name" : "337", - "y" : 7 + "y" : 11 }, { "drilldown" : "336", @@ -832,7 +832,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index d4229c3f0f..7d8995b995 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,7 +10,7 @@ "data" : [ [ "Perl", - 17342 + 17346 ], [ "Raku", @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index fa1be9832a..33caeb0b61 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -456,7 +456,7 @@ "data" : [ [ "Perl", - 412 + 414 ] ], "id" : "Niels van Dijke", @@ -937,7 +937,7 @@ { "drilldown" : "Niels van Dijke", "name" : "29: Niels van Dijke", - "y" : 824 + "y" : 828 }, { "drilldown" : "Duncan C. White", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index 140e540f73..8dc7936d28 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -28,7 +28,7 @@ 44, 13, 8, - 72, + 74, 22, 8, 1, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-121-150.json b/stats/pwc-summary-121-150.json index 26459d8811..4c19274afe 100644 --- a/stats/pwc-summary-121-150.json +++ b/stats/pwc-summary-121-150.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-151-180.json b/stats/pwc-summary-151-180.json index 604aaa2562..3e6247807a 100644 --- a/stats/pwc-summary-151-180.json +++ b/stats/pwc-summary-151-180.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-181-210.json b/stats/pwc-summary-181-210.json index 337f41f3c7..8813733324 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -37,7 +37,7 @@ 88, 8, 1, - 412, + 414, 2, 0 ], @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-211-240.json b/stats/pwc-summary-211-240.json index ad93e69534..8f1ae1a840 100644 --- a/stats/pwc-summary-211-240.json +++ b/stats/pwc-summary-211-240.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-241-270.json b/stats/pwc-summary-241-270.json index 3635160b0a..5851ea8c40 100644 --- a/stats/pwc-summary-241-270.json +++ b/stats/pwc-summary-241-270.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-271-300.json b/stats/pwc-summary-271-300.json index bc2bf39892..2c95433df7 100644 --- a/stats/pwc-summary-271-300.json +++ b/stats/pwc-summary-271-300.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-301-330.json b/stats/pwc-summary-301-330.json index b4c3c2e2b6..9b4f6db8ba 100644 --- a/stats/pwc-summary-301-330.json +++ b/stats/pwc-summary-301-330.json @@ -109,7 +109,7 @@ } ], "subtitle" : { - "text" : "[Champions: 28] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 28] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-31-60.json b/stats/pwc-summary-31-60.json index bf0f748be9..e6e2db1822 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-61-90.json b/stats/pwc-summary-61-90.json index 8f71f1a0a6..3cf04691a3 100644 --- a/stats/pwc-summary-61-90.json +++ b/stats/pwc-summary-61-90.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary-91-120.json b/stats/pwc-summary-91-120.json index 3ec7705158..7474e5c4e4 100644 --- a/stats/pwc-summary-91-120.json +++ b/stats/pwc-summary-91-120.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 30] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index 7ff73da187..576582895b 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -28,7 +28,7 @@ 26, 9, 4, - 36, + 37, 11, 4, 1, @@ -217,7 +217,7 @@ 45, 4, 1, - 213, + 214, 1, 0, 26, @@ -1009,7 +1009,7 @@ } ], "subtitle" : { - "text" : "[Champions: 328] Last updated at 2025-09-01 12:14:57 GMT" + "text" : "[Champions: 328] Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-yearly-language-summary.json b/stats/pwc-yearly-language-summary.json index be85a12230..e43d45c0c6 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,7 +8,7 @@ "data" : [ [ "Perl", - 1571 + 1575 ], [ "Raku", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 3004 + "y" : 3008 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 12:14:57 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-09-01 13:42:46 GMT" }, "title" : { "text" : "The Weekly Challenge Language" -- cgit