diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-10-20 17:28:01 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-10-20 17:28:01 +0100 |
| commit | 5fbd95540e261ce974dfcf7ee37057fa112524ba (patch) | |
| tree | bc53857358d8db03b03e7ed0709d19eaf37a9e31 | |
| parent | b28347c3d3d328d3542e58bc94663c7af540b217 (diff) | |
| download | perlweeklychallenge-club-5fbd95540e261ce974dfcf7ee37057fa112524ba.tar.gz perlweeklychallenge-club-5fbd95540e261ce974dfcf7ee37057fa112524ba.tar.bz2 perlweeklychallenge-club-5fbd95540e261ce974dfcf7ee37057fa112524ba.zip | |
- Added solutions to task #1 of week #344.
26 files changed, 119 insertions, 40 deletions
diff --git a/challenge-344/mohammad-anwar/perl/ch-1.pl b/challenge-344/mohammad-anwar/perl/ch-1.pl new file mode 100644 index 0000000000..49279d6fff --- /dev/null +++ b/challenge-344/mohammad-anwar/perl/ch-1.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl + +use Test::More; +use Test::Deep; + +my @examples = ( + { input => { arr => [1, 2, 3, 4], x => 12 }, exp => [1, 2, 4, 6] }, + { input => { arr => [2, 7, 4], x => 181 }, exp => [4, 5, 5] }, + { input => { arr => [9, 9, 9], x => 1 }, exp => [1, 0, 0, 0] }, + { input => { arr => [1, 0, 0, 0, 0], x => 9999 }, exp => [1, 9, 9, 9, 9] }, + { input => { arr => [0], x => 1000 }, exp => [1, 0, 0, 0] }, +); + +foreach my $example (@examples) { + is_deeply([add_to_array_form($example->{input}{arr}, $example->{input}{x})], + $example->{exp}); +} + +done_testing; + +sub add_to_array_form { map $_+0, split //, join('', @{$_[0]}) + $_[1] } diff --git a/challenge-344/mohammad-anwar/python/ch-1.py b/challenge-344/mohammad-anwar/python/ch-1.py new file mode 100644 index 0000000000..2df1b1167a --- /dev/null +++ b/challenge-344/mohammad-anwar/python/ch-1.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +def add_to_array_form(arr, x): + return [int(d) for d in str(int(''.join(map(str, arr))) + x)] + +if __name__ == "__main__": + examples = [ + {"input": {"arr": [1, 2, 3, 4], "x": 12}, "exp": [1, 2, 4, 6]}, + {"input": {"arr": [2, 7, 4], "x": 181}, "exp": [4, 5, 5]}, + {"input": {"arr": [9, 9, 9], "x": 1}, "exp": [1, 0, 0, 0]}, + {"input": {"arr": [1, 0, 0, 0, 0], "x": 9999}, "exp": [1, 9, 9, 9, 9]}, + {"input": {"arr": [0], "x": 1000}, "exp": [1, 0, 0, 0]}, + ] + + for example in examples: + result = add_to_array_form(example["input"]["arr"], example["input"]["x"]) + assert result == example["exp"], f"Expected {example['exp']}, got {result}" + + print("All tests passed!") diff --git a/challenge-344/mohammad-anwar/raku/ch-1.raku b/challenge-344/mohammad-anwar/raku/ch-1.raku new file mode 100644 index 0000000000..d13df99ffc --- /dev/null +++ b/challenge-344/mohammad-anwar/raku/ch-1.raku @@ -0,0 +1,20 @@ +#!/usr/bin/env raku + +use Test; + +my @examples = ( + { input => { arr => [1, 2, 3, 4], x => 12 }, exp => [1, 2, 4, 6] }, + { input => { arr => [2, 7, 4], x => 181 }, exp => [4, 5, 5] }, + { input => { arr => [9, 9, 9], x => 1 }, exp => [1, 0, 0, 0] }, + { input => { arr => [1, 0, 0, 0, 0], x => 9999 }, exp => [1, 9, 9, 9, 9] }, + { input => { arr => [0], x => 1000 }, exp => [1, 0, 0, 0] }, +); + +for @examples -> $example { + is-deeply([add-to-array-form($example<input><arr>, $example<input><x>)], + $example<exp>); +} + +done-testing; + +sub add-to-array-form($arr, $x) { ($arr.join('') + $x).combĀ».Int } diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 46dd289809..ee12bffa2a 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -72,6 +72,20 @@ "data" : [ [ "Perl", + 1 + ], + [ + "Raku", + 1 + ] + ], + "id" : "Mohammad Sajid Anwar", + "name" : "Mohammad Sajid Anwar" + }, + { + "data" : [ + [ + "Perl", 2 ] ], @@ -127,6 +141,11 @@ "y" : 2 }, { + "drilldown" : "Mohammad Sajid Anwar", + "name" : "Mohammad Sajid Anwar", + "y" : 2 + }, + { "drilldown" : "Vinod Kumar K", "name" : "Vinod Kumar K", "y" : 2 @@ -136,7 +155,7 @@ } ], "subtitle" : { - "text" : "[Champions: 7] Last updated at 2025-10-20 16:05:42 GMT" + "text" : "[Champions: 8] Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge - 344" diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json index 64e7d2b62e..45e423fc93 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json index ee9c169deb..2b3dc07f1a 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json index 9c4e73a823..bba4eef626 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json index 60b461f64b..988f8133ed 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json index b1ef33258e..bf4d306f27 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json index efdc39f4d0..9550bbe3f0 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-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json index 08f667c74a..174db5713e 100644 --- a/stats/pwc-language-breakdown-2025.json +++ b/stats/pwc-language-breakdown-2025.json @@ -8,11 +8,11 @@ "data" : [ [ "Perl", - 8 + 9 ], [ "Raku", - 6 + 7 ], [ "Blog", @@ -781,7 +781,7 @@ { "drilldown" : "344", "name" : "344", - "y" : 16 + "y" : 18 }, { "drilldown" : "343", @@ -993,7 +993,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index b0eeed117a..4f664d7e6e 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -10,11 +10,11 @@ "data" : [ [ "Perl", - 17707 + 17708 ], [ "Raku", - 9825 + 9826 ], [ "Blog", @@ -37,7 +37,7 @@ } ], "subtitle" : { - "text" : "Last updated at 2025-10-20 16:05:42 GMT" + "text" : "Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2025]" diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 2264cf41d3..ae08087245 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -480,11 +480,11 @@ "data" : [ [ "Perl", - 176 + 177 ], [ "Raku", - 109 + 110 ], [ "Blog", @@ -947,7 +947,7 @@ { "drilldown" : "Mohammad Sajid Anwar", "name" : "31: Mohammad Sajid Anwar", - "y" : 732 + "y" : 736 }, { "drilldown" : "Robert Ransbottom", @@ -1049,7 +1049,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "Team Leaders (TOP 50)" diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json index fa62bcd939..8d15375fd2 100644 --- a/stats/pwc-summary-1-30.json +++ b/stats/pwc-summary-1-30.json @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 0b5a3c6021..c29295cca9 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 7453f6fef4..ebe94dd944 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 609094edfe..d1082b5ab2 100644 --- a/stats/pwc-summary-181-210.json +++ b/stats/pwc-summary-181-210.json @@ -28,7 +28,7 @@ 0, 0, 1, - 176, + 177, 0, 0, 40, @@ -63,7 +63,7 @@ 2, 0, 0, - 109, + 110, 1, 10, 40, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 66740366d8..2205a43b39 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 25711ecf1d..8e508ec590 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 a6e0a7f519..c638565a28 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 68486f57d7..84254acf54 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-10-20 16:05:42 GMT" + "text" : "[Champions: 28] Last updated at 2025-10-20 16:27:38 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 47fe82948e..96939c4397 100644 --- a/stats/pwc-summary-31-60.json +++ b/stats/pwc-summary-31-60.json @@ -69,8 +69,8 @@ 9, 0, 0, - 2, 17, + 2, 0, 194, 0, @@ -115,7 +115,7 @@ } ], "subtitle" : { - "text" : "[Champions: 30] Last updated at 2025-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 b2ee0d9b7b..7bf2771683 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 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 871ae78cb6..90aabbdeff 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-10-20 16:05:42 GMT" + "text" : "[Champions: 30] Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge [2019 - 2025]" diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json index 11e773cdc6..20c2927250 100644 --- a/stats/pwc-summary.json +++ b/stats/pwc-summary.json @@ -208,7 +208,7 @@ 0, 0, 1, - 110, + 111, 0, 0, 20, @@ -397,8 +397,8 @@ 6, 0, 0, - 9, 1, + 9, 0, 104, 0, @@ -541,7 +541,7 @@ 1, 0, 0, - 68, + 69, 1, 5, 20, @@ -1009,7 +1009,7 @@ } ], "subtitle" : { - "text" : "[Champions: 328] Last updated at 2025-10-20 16:05:42 GMT" + "text" : "[Champions: 328] Last updated at 2025-10-20 16:27:38 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 20e6caacec..f9a27ebcb0 100644 --- a/stats/pwc-yearly-language-summary.json +++ b/stats/pwc-yearly-language-summary.json @@ -8,11 +8,11 @@ "data" : [ [ "Perl", - 1930 + 1931 ], [ "Raku", - 949 + 950 ], [ "Blog", @@ -151,7 +151,7 @@ { "drilldown" : "2025", "name" : "2025", - "y" : 3635 + "y" : 3637 }, { "drilldown" : "2024", @@ -188,7 +188,7 @@ } ], "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:05:42 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-20 16:27:38 GMT" }, "title" : { "text" : "The Weekly Challenge Language" |
