aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-10-28 16:17:12 +0000
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-10-28 16:17:12 +0000
commitc6c0ff17754ba5eaeaee30d6686b674f4a940674 (patch)
tree50548cc4ce3729410d0c3975cdfc9f8ac1c23890
parent8fbc20a0a3c2910b80f5f7bcd915bf6e63053828 (diff)
downloadperlweeklychallenge-club-c6c0ff17754ba5eaeaee30d6686b674f4a940674.tar.gz
perlweeklychallenge-club-c6c0ff17754ba5eaeaee30d6686b674f4a940674.tar.bz2
perlweeklychallenge-club-c6c0ff17754ba5eaeaee30d6686b674f4a940674.zip
- Added solutions to task #1 of week #345.
-rw-r--r--challenge-345/mohammad-anwar/perl/ch-1.pl28
-rw-r--r--challenge-345/mohammad-anwar/python/ch-1.py27
-rw-r--r--challenge-345/mohammad-anwar/raku/ch-1.raku25
-rw-r--r--stats/pwc-current.json21
-rw-r--r--stats/pwc-language-breakdown-2019.json2
-rw-r--r--stats/pwc-language-breakdown-2020.json2
-rw-r--r--stats/pwc-language-breakdown-2021.json2
-rw-r--r--stats/pwc-language-breakdown-2022.json2
-rw-r--r--stats/pwc-language-breakdown-2023.json2
-rw-r--r--stats/pwc-language-breakdown-2024.json2
-rw-r--r--stats/pwc-language-breakdown-2025.json8
-rw-r--r--stats/pwc-language-breakdown-summary.json6
-rw-r--r--stats/pwc-leaders.json8
-rw-r--r--stats/pwc-summary-1-30.json2
-rw-r--r--stats/pwc-summary-121-150.json2
-rw-r--r--stats/pwc-summary-151-180.json2
-rw-r--r--stats/pwc-summary-181-210.json6
-rw-r--r--stats/pwc-summary-211-240.json2
-rw-r--r--stats/pwc-summary-241-270.json2
-rw-r--r--stats/pwc-summary-271-300.json2
-rw-r--r--stats/pwc-summary-301-330.json2
-rw-r--r--stats/pwc-summary-31-60.json2
-rw-r--r--stats/pwc-summary-61-90.json2
-rw-r--r--stats/pwc-summary-91-120.json2
-rw-r--r--stats/pwc-summary.json8
-rw-r--r--stats/pwc-yearly-language-summary.json8
26 files changed, 138 insertions, 39 deletions
diff --git a/challenge-345/mohammad-anwar/perl/ch-1.pl b/challenge-345/mohammad-anwar/perl/ch-1.pl
new file mode 100644
index 0000000000..5d5b3cc855
--- /dev/null
+++ b/challenge-345/mohammad-anwar/perl/ch-1.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+
+my @examples = (
+ { in => [1, 3, 2], exp => "1" },
+ { in => [2, 4, 6, 5, 3], exp => "2" },
+ { in => [1, 2, 3, 2, 4, 1], exp => "2, 4" },
+ { in => [5, 3, 1], exp => "0" },
+ { in => [1, 5, 1, 5, 1, 5, 1], exp => "1, 3, 5" },
+);
+
+foreach (@examples) {
+ is(peak_point(@{$_->{in}}), $_->{exp});
+}
+
+done_testing;
+
+sub peak_point {
+ my @n = @_;
+ return join(", ", grep {
+ ($_ == 0 ? @n > 1 && $n[0] > $n[1] :
+ $_ == $#n ? @n > 1 && $n[-1] > $n[-2] :
+ $n[$_] > $n[$_-1] && $n[$_] > $n[$_+1])
+ } 0..$#n);
+}
diff --git a/challenge-345/mohammad-anwar/python/ch-1.py b/challenge-345/mohammad-anwar/python/ch-1.py
new file mode 100644
index 0000000000..63fe17a864
--- /dev/null
+++ b/challenge-345/mohammad-anwar/python/ch-1.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+def peak_point(nums):
+ n = nums
+ return ", ".join(str(i) for i in range(len(n)) if
+ (i == 0 and len(n) > 1 and n[0] > n[1]) or
+ (i == len(n) - 1 and len(n) > 1 and n[-1] > n[-2]) or
+ (0 < i < len(n) - 1 and n[i] > n[i-1] and n[i] > n[i+1]))
+
+def test_examples():
+ examples = [
+ {"in": [1, 3, 2], "exp": "1"},
+ {"in": [2, 4, 6, 5, 3], "exp": "2"},
+ {"in": [1, 2, 3, 2, 4, 1], "exp": "2, 4"},
+ {"in": [5, 3, 1], "exp": "0"},
+ {"in": [1, 5, 1, 5, 1, 5, 1], "exp": "1, 3, 5"},
+ ]
+
+ for example in examples:
+ result = peak_point(example["in"])
+ expected = example["exp"]
+ assert result == expected, f"Failed for {example['in']}: expected '{expected}', got '{result}'"
+ print(f"{example['in']} -> {result}")
+
+if __name__ == "__main__":
+ test_examples()
+ print("All tests passed!")
diff --git a/challenge-345/mohammad-anwar/raku/ch-1.raku b/challenge-345/mohammad-anwar/raku/ch-1.raku
new file mode 100644
index 0000000000..b087e313d9
--- /dev/null
+++ b/challenge-345/mohammad-anwar/raku/ch-1.raku
@@ -0,0 +1,25 @@
+#!/usr/bin/env raku
+
+use Test;
+
+my @examples = (
+ { in => [1, 3, 2], exp => "1" },
+ { in => [2, 4, 6, 5, 3], exp => "2" },
+ { in => [1, 2, 3, 2, 4, 1], exp => "2, 4" },
+ { in => [5, 3, 1], exp => "0" },
+ { in => [1, 5, 1, 5, 1, 5, 1], exp => "1, 3, 5" },
+);
+
+for @examples -> %example {
+ is(peak-point(%example<in>), %example<exp>);
+}
+
+done-testing;
+
+sub peak-point(@n) {
+ return @n.keys.grep({
+ $_ == 0 ?? @n > 1 && @n[0] > @n[1] !!
+ $_ == @n.end ?? @n > 1 && @n[*-1] > @n[*-2] !!
+ @n[$_] > @n[$_ - 1] && @n[$_] > @n[$_ + 1]
+ }).join(", ");
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index 05d50f23f2..8540263b03 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -92,6 +92,20 @@
"data" : [
[
"Perl",
+ 1
+ ],
+ [
+ "Raku",
+ 1
+ ]
+ ],
+ "id" : "Mohammad Sajid Anwar",
+ "name" : "Mohammad Sajid Anwar"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
2
],
[
@@ -189,6 +203,11 @@
"y" : 2
},
{
+ "drilldown" : "Mohammad Sajid Anwar",
+ "name" : "Mohammad Sajid Anwar",
+ "y" : 2
+ },
+ {
"drilldown" : "Peter Campbell Smith",
"name" : "Peter Campbell Smith",
"y" : 3
@@ -208,7 +227,7 @@
}
],
"subtitle" : {
- "text" : "[Champions: 11] Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "[Champions: 12] Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge - 345"
diff --git a/stats/pwc-language-breakdown-2019.json b/stats/pwc-language-breakdown-2019.json
index ac746326ab..be4b3c8e73 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2020.json b/stats/pwc-language-breakdown-2020.json
index de1dfe2047..b0a4b8a6cb 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2021.json b/stats/pwc-language-breakdown-2021.json
index 14d52e2301..2627b7eb2b 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2022.json b/stats/pwc-language-breakdown-2022.json
index 9efabd8756..507b710a40 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2023.json b/stats/pwc-language-breakdown-2023.json
index dd15d7e41a..2c9baad92e 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2024.json b/stats/pwc-language-breakdown-2024.json
index be2eeb30f0..5d36413675 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-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-2025.json b/stats/pwc-language-breakdown-2025.json
index f70c654049..47a8158d0e 100644
--- a/stats/pwc-language-breakdown-2025.json
+++ b/stats/pwc-language-breakdown-2025.json
@@ -8,11 +8,11 @@
"data" : [
[
"Perl",
- 16
+ 17
],
[
"Raku",
- 6
+ 7
],
[
"Blog",
@@ -799,7 +799,7 @@
{
"drilldown" : "345",
"name" : "345",
- "y" : 27
+ "y" : 29
},
{
"drilldown" : "344",
@@ -1016,7 +1016,7 @@
}
],
"subtitle" : {
- "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"
diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json
index d563a08d23..e061684abc 100644
--- a/stats/pwc-language-breakdown-summary.json
+++ b/stats/pwc-language-breakdown-summary.json
@@ -10,11 +10,11 @@
"data" : [
[
"Perl",
- 17762
+ 17763
],
[
"Raku",
- 9850
+ 9851
],
[
"Blog",
@@ -37,7 +37,7 @@
}
],
"subtitle" : {
- "text" : "Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Contributions [2019 - 2025]"
diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json
index c25af5d2d5..c8f522cefc 100644
--- a/stats/pwc-leaders.json
+++ b/stats/pwc-leaders.json
@@ -480,11 +480,11 @@
"data" : [
[
"Perl",
- 177
+ 178
],
[
"Raku",
- 110
+ 111
],
[
"Blog",
@@ -947,7 +947,7 @@
{
"drilldown" : "Mohammad Sajid Anwar",
"name" : "31: Mohammad Sajid Anwar",
- "y" : 736
+ "y" : 740
},
{
"drilldown" : "Robert Ransbottom",
@@ -1049,7 +1049,7 @@
}
],
"subtitle" : {
- "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the score breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "Team Leaders (TOP 50)"
diff --git a/stats/pwc-summary-1-30.json b/stats/pwc-summary-1-30.json
index d8d3c7887b..fdebf90d1e 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 b1b595ba70..e790801307 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 fc5e47c236..a6c73830b7 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 f9023f692b..ad0b9e65e0 100644
--- a/stats/pwc-summary-181-210.json
+++ b/stats/pwc-summary-181-210.json
@@ -28,7 +28,7 @@
0,
0,
1,
- 177,
+ 178,
0,
0,
40,
@@ -63,7 +63,7 @@
2,
0,
0,
- 110,
+ 111,
1,
10,
40,
@@ -115,7 +115,7 @@
}
],
"subtitle" : {
- "text" : "[Champions: 30] Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 28f3666dc8..3b42407bb2 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 6cfd998c71..0b5324a23e 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 6a59ac8bad..4a4ba2d6c7 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 2b80ac9273..69eacd5a2c 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-27 23:20:54 GMT"
+ "text" : "[Champions: 28] Last updated at 2025-10-28 16:17:05 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 0b9c908b74..6a32c7f8f2 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-10-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 54621aff00..7d0bf9cc00 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 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 06c48a3f26..1a4fcc1719 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-27 23:20:54 GMT"
+ "text" : "[Champions: 30] Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge [2019 - 2025]"
diff --git a/stats/pwc-summary.json b/stats/pwc-summary.json
index 4df8445c09..e39832e145 100644
--- a/stats/pwc-summary.json
+++ b/stats/pwc-summary.json
@@ -208,7 +208,7 @@
0,
0,
1,
- 111,
+ 112,
0,
0,
20,
@@ -397,8 +397,8 @@
6,
0,
0,
- 1,
9,
+ 1,
0,
104,
0,
@@ -541,7 +541,7 @@
1,
0,
0,
- 69,
+ 70,
1,
5,
20,
@@ -1009,7 +1009,7 @@
}
],
"subtitle" : {
- "text" : "[Champions: 328] Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "[Champions: 328] Last updated at 2025-10-28 16:17:05 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 6e4606e63b..d117e3f0d8 100644
--- a/stats/pwc-yearly-language-summary.json
+++ b/stats/pwc-yearly-language-summary.json
@@ -8,11 +8,11 @@
"data" : [
[
"Perl",
- 1985
+ 1986
],
[
"Raku",
- 974
+ 975
],
[
"Blog",
@@ -151,7 +151,7 @@
{
"drilldown" : "2025",
"name" : "2025",
- "y" : 3735
+ "y" : 3737
},
{
"drilldown" : "2024",
@@ -188,7 +188,7 @@
}
],
"subtitle" : {
- "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-27 23:20:54 GMT"
+ "text" : "Click the columns to drilldown the language breakdown. Last updated at 2025-10-28 16:17:05 GMT"
},
"title" : {
"text" : "The Weekly Challenge Language"