aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-11-03 16:28:44 +0000
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-11-03 16:28:44 +0000
commitf8b0c995453b3f8f084ce86ed86a1e92cfebfe8e (patch)
tree70766886434f7974e4a102200b2e78ffab135a5d
parent63e805992e5c9c036383aafd85519ed8259e9339 (diff)
downloadperlweeklychallenge-club-f8b0c995453b3f8f084ce86ed86a1e92cfebfe8e.tar.gz
perlweeklychallenge-club-f8b0c995453b3f8f084ce86ed86a1e92cfebfe8e.tar.bz2
perlweeklychallenge-club-f8b0c995453b3f8f084ce86ed86a1e92cfebfe8e.zip
- Added solutions by Mark Anderson.
- Added solutions by E. Choroba. - Added solutions by Lubos Kolouch. - Added solutions by Eric Cheung. - Added solutions by Andreas Mahnke. - Added solutions by Mohammad Sajid Anwar.
-rwxr-xr-xchallenge-346/eric-cheung/python/ch-1.py24
-rwxr-xr-xchallenge-346/eric-cheung/python/ch-2.py48
-rw-r--r--challenge-346/mohammad-anwar/perl/ch-1.pl41
-rw-r--r--challenge-346/mohammad-anwar/python/ch-1.py36
-rw-r--r--challenge-346/mohammad-anwar/raku/ch-1.raku39
-rw-r--r--stats/pwc-challenge-331.json17
-rw-r--r--stats/pwc-challenge-345.json574
-rw-r--r--stats/pwc-current.json453
-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.json29
-rw-r--r--stats/pwc-language-breakdown-summary.json6
-rw-r--r--stats/pwc-leaders.json20
-rw-r--r--stats/pwc-summary-1-30.json4
-rw-r--r--stats/pwc-summary-121-150.json2
-rw-r--r--stats/pwc-summary-151-180.json6
-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.json4
-rw-r--r--stats/pwc-summary-61-90.json4
-rw-r--r--stats/pwc-summary-91-120.json2
-rw-r--r--stats/pwc-summary.json16
-rw-r--r--stats/pwc-yearly-language-summary.json8
30 files changed, 856 insertions, 503 deletions
diff --git a/challenge-346/eric-cheung/python/ch-1.py b/challenge-346/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..4ed5e07a06
--- /dev/null
+++ b/challenge-346/eric-cheung/python/ch-1.py
@@ -0,0 +1,24 @@
+
+## strInput = "(()())" ## Example 1
+## strInput = ")()())" ## Example 2
+## strInput = "((()))()(((()" ## Example 3
+## strInput = "))))((()(" ## Example 4
+strInput = "()(()" ## Example 5
+
+strTemp = strInput
+nLastPosFind = len(strInput)
+arrPos = []
+nCount = 0
+
+while (nPos := strTemp.find("()")) > -1:
+ if nPos > nLastPosFind:
+ arrPos.append(nCount)
+ nCount = 0
+
+ strTemp = strTemp[:nPos] + strTemp[nPos + 2:]
+ nLastPosFind = nPos
+ nCount = nCount + 2
+
+arrPos.append(nCount)
+
+print (max(arrPos))
diff --git a/challenge-346/eric-cheung/python/ch-2.py b/challenge-346/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..9b606a0e23
--- /dev/null
+++ b/challenge-346/eric-cheung/python/ch-2.py
@@ -0,0 +1,48 @@
+
+from itertools import product
+from re import findall
+
+## Example 1
+## strInput = "123"
+## nTarget = 6
+
+## Example 2
+## strInput = "105"
+## nTarget = 5
+
+## Example 3
+## strInput = "232"
+## nTarget = 8
+
+## Example 4
+## strInput = "1234"
+## nTarget = 10
+
+## Example 5
+strInput = "1001"
+nTarget = 2
+
+arrOutput = []
+
+arrChar = ["", "+", "-", "*"]
+arrCartChar = [arrChar] * (len(strInput) - 1)
+
+strExpr = "%".join([("" if nIndx == 0 else str(nIndx)) + charLoop for nIndx, charLoop in enumerate(list(strInput))])
+
+arrAllList = list(product(*arrCartChar))
+arrToRep = ["%" + str(nIndx) for nIndx in range(1, len(strInput))]
+
+for arrLoop in arrAllList:
+ strTemp = strExpr
+ for strToRep, strNuStr in zip(arrToRep, arrLoop):
+ strTemp = strTemp.replace(strToRep, strNuStr)
+
+ if findall("0[0-9]", strTemp):
+ continue
+
+ if eval(strTemp) != nTarget:
+ continue
+
+ arrOutput.append(strTemp)
+
+print (arrOutput)
diff --git a/challenge-346/mohammad-anwar/perl/ch-1.pl b/challenge-346/mohammad-anwar/perl/ch-1.pl
new file mode 100644
index 0000000000..0d5848c681
--- /dev/null
+++ b/challenge-346/mohammad-anwar/perl/ch-1.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+
+my @examples = (
+ { str => '(()())', exp => 6 },
+ { str => ')()())', exp => 4 },
+ { str => '((()))()(((()', exp => 8 },
+ { str => '))))((()(', exp => 2 },
+ { str => '()(()', exp => 2 },
+);
+
+foreach (@examples) {
+ is(valid_longest_parenthesis($_->{str}), $_->{exp});
+}
+
+done_testing;
+
+sub valid_longest_parenthesis {
+ my $s = shift;
+ my @stack = (-1);
+ my $max_len = 0;
+
+ for my $i (0 .. length($s) - 1) {
+ if (substr($s, $i, 1) eq "(") {
+ push @stack, $i;
+ } else {
+ pop @stack;
+ if (@stack) {
+ $max_len = $max_len > ($i - $stack[-1])
+ ? $max_len : ($i - $stack[-1]);
+ } else {
+ push @stack, $i; # New starting point
+ }
+ }
+ }
+
+ return $max_len;
+}
diff --git a/challenge-346/mohammad-anwar/python/ch-1.py b/challenge-346/mohammad-anwar/python/ch-1.py
new file mode 100644
index 0000000000..9bdbf3be9e
--- /dev/null
+++ b/challenge-346/mohammad-anwar/python/ch-1.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+def valid_longest_parenthesis(s):
+ stack = [-1]
+ max_len = 0
+
+ for i in range(len(s)):
+ if s[i] == "(":
+ stack.append(i)
+ else:
+ stack.pop()
+ if stack:
+ max_len = max(max_len, i - stack[-1])
+ else:
+ stack.append(i) # New starting point
+
+ return max_len
+
+def test_examples():
+ examples = [
+ {"str": "(()())", "exp": 6},
+ {"str": ")()())", "exp": 4},
+ {"str": "((()))()(((()", "exp": 8},
+ {"str": "))))((()(", "exp": 2},
+ {"str": "()(()", "exp": 2},
+ ]
+
+ for example in examples:
+ result = valid_longest_parenthesis(example["str"])
+ expected = example["exp"]
+ assert result == expected, f"Failed for '{example['str']}': expected {expected}, got {result}"
+ print(f"✓ '{example['str']}' -> {result}")
+
+if __name__ == "__main__":
+ test_examples()
+ print("All tests passed!")
diff --git a/challenge-346/mohammad-anwar/raku/ch-1.raku b/challenge-346/mohammad-anwar/raku/ch-1.raku
new file mode 100644
index 0000000000..31183d0c27
--- /dev/null
+++ b/challenge-346/mohammad-anwar/raku/ch-1.raku
@@ -0,0 +1,39 @@
+#!/usr/bin/env raku
+
+use Test;
+
+my @examples = (
+ { str => '(()())', exp => 6 },
+ { str => ')()())', exp => 4 },
+ { str => '((()))()(((()', exp => 8 },
+ { str => '))))((()(', exp => 2 },
+ { str => '()(()', exp => 2 },
+);
+
+for @examples -> %example {
+ is(valid-longest-parenthesis(%example<str>), %example<exp>);
+}
+
+done-testing;
+
+sub valid-longest-parenthesis(Str $s) {
+ my @stack = (-1);
+ my $max-len = 0;
+
+ for 0 .. $s.chars - 1 -> $i {
+ if $s.substr($i, 1) eq "(" {
+ @stack.push($i);
+ } else {
+ @stack.pop();
+ if @stack.elems > 0 {
+ $max-len = $max-len > ($i - @stack[*-1])
+ ?? $max-len
+ !! ($i - @stack[*-1]);
+ } else {
+ @stack.push($i); # New starting point
+ }
+ }
+ }
+
+ return $max-len;
+}
diff --git a/stats/pwc-challenge-331.json b/stats/pwc-challenge-331.json
index fd040ad2e2..e7963f2e13 100644
--- a/stats/pwc-challenge-331.json
+++ b/stats/pwc-challenge-331.json
@@ -191,6 +191,16 @@
{
"data" : [
[
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Lubos Kolouch",
+ "name" : "Lubos Kolouch"
+ },
+ {
+ "data" : [
+ [
"Raku",
2
],
@@ -525,6 +535,11 @@
"y" : 2
},
{
+ "drilldown" : "Lubos Kolouch",
+ "name" : "Lubos Kolouch",
+ "y" : 2
+ },
+ {
"drilldown" : "Luca Ferrari",
"name" : "Luca Ferrari",
"y" : 12
@@ -624,7 +639,7 @@
}
],
"subtitle" : {
- "text" : "[Champions: 35] Last updated at 2025-07-31 10:32:18 GMT"
+ "text" : "[Champions: 36] Last updated at 2025-11-03 16:24:29 GMT"
},
"title" : {
"text" : "The Weekly Challenge - 331"
diff --git a/stats/pwc-challenge-345.json b/stats/pwc-challenge-345.json
new file mode 100644
index 0000000000..7c29b8f128
--- /dev/null
+++ b/stats/pwc-challenge-345.json
@@ -0,0 +1,574 @@
+{
+ "chart" : {
+ "type" : "column"
+ },
+ "drilldown" : {
+ "series" : [
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Ali Moradi",
+ "name" : "Ali Moradi"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Andreas Mahnke",
+ "name" : "Andreas Mahnke"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Andrew Shitov",
+ "name" : "Andrew Shitov"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Arne Sommer",
+ "name" : "Arne Sommer"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Athanasius",
+ "name" : "Athanasius"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 1
+ ]
+ ],
+ "id" : "BarrOff",
+ "name" : "BarrOff"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Bob Lied",
+ "name" : "Bob Lied"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "David Ferrone",
+ "name" : "David Ferrone"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "E. Choroba",
+ "name" : "E. Choroba"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Feng Chang",
+ "name" : "Feng Chang"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Jaldhar H. Vyas",
+ "name" : "Jaldhar H. Vyas"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Jorg Sommrey",
+ "name" : "Jorg Sommrey"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Kjetil Skotheim",
+ "name" : "Kjetil Skotheim"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Lubos Kolouch",
+ "name" : "Lubos Kolouch"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Mark Anderson",
+ "name" : "Mark Anderson"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Matthew Neleigh",
+ "name" : "Matthew Neleigh"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Matthias Muth",
+ "name" : "Matthias Muth"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 1
+ ],
+ [
+ "Raku",
+ 1
+ ]
+ ],
+ "id" : "Mohammad Sajid Anwar",
+ "name" : "Mohammad Sajid Anwar"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Packy Anderson",
+ "name" : "Packy Anderson"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Peter Campbell Smith",
+ "name" : "Peter Campbell Smith"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Peter Meszaros",
+ "name" : "Peter Meszaros"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Robbie Hatley",
+ "name" : "Robbie Hatley"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Robert Ransbottom",
+ "name" : "Robert Ransbottom"
+ },
+ {
+ "data" : [
+ [
+ "Raku",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Roger Bell_West",
+ "name" : "Roger Bell_West"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Simon Green",
+ "name" : "Simon Green"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 2
+ ]
+ ],
+ "id" : "Thomas Kohler",
+ "name" : "Thomas Kohler"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Raku",
+ 2
+ ]
+ ],
+ "id" : "Ulrich Rieke",
+ "name" : "Ulrich Rieke"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "Vinod Kumar K",
+ "name" : "Vinod Kumar K"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ],
+ [
+ "Blog",
+ 1
+ ]
+ ],
+ "id" : "W. Luis Mochan",
+ "name" : "W. Luis Mochan"
+ },
+ {
+ "data" : [
+ [
+ "Perl",
+ 2
+ ]
+ ],
+ "id" : "Wanderdoc",
+ "name" : "Wanderdoc"
+ }
+ ]
+ },
+ "legend" : {
+ "enabled" : 0
+ },
+ "plotOptions" : {
+ "series" : {
+ "borderWidth" : 0,
+ "dataLabels" : {
+ "enabled" : 1,
+ "format" : "{point.y}"
+ }
+ }
+ },
+ "series" : [
+ {
+ "colorByPoint" : 1,
+ "data" : [
+ {
+ "drilldown" : "Ali Moradi",
+ "name" : "Ali Moradi",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Andreas Mahnke",
+ "name" : "Andreas Mahnke",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Andrew Shitov",
+ "name" : "Andrew Shitov",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Arne Sommer",
+ "name" : "Arne Sommer",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Athanasius",
+ "name" : "Athanasius",
+ "y" : 4
+ },
+ {
+ "drilldown" : "BarrOff",
+ "name" : "BarrOff",
+ "y" : 1
+ },
+ {
+ "drilldown" : "Bob Lied",
+ "name" : "Bob Lied",
+ "y" : 3
+ },
+ {
+ "drilldown" : "David Ferrone",
+ "name" : "David Ferrone",
+ "y" : 2
+ },
+ {
+ "drilldown" : "E. Choroba",
+ "name" : "E. Choroba",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Feng Chang",
+ "name" : "Feng Chang",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Jaldhar H. Vyas",
+ "name" : "Jaldhar H. Vyas",
+ "y" : 5
+ },
+ {
+ "drilldown" : "Jorg Sommrey",
+ "name" : "Jorg Sommrey",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Kjetil Skotheim",
+ "name" : "Kjetil Skotheim",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Lubos Kolouch",
+ "name" : "Lubos Kolouch",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Mark Anderson",
+ "name" : "Mark Anderson",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Matthew Neleigh",
+ "name" : "Matthew Neleigh",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Matthias Muth",
+ "name" : "Matthias Muth",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Mohammad Sajid Anwar",
+ "name" : "Mohammad Sajid Anwar",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Packy Anderson",
+ "name" : "Packy Anderson",
+ "y" : 5
+ },
+ {
+ "drilldown" : "Peter Campbell Smith",
+ "name" : "Peter Campbell Smith",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Peter Meszaros",
+ "name" : "Peter Meszaros",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Robbie Hatley",
+ "name" : "Robbie Hatley",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Robert Ransbottom",
+ "name" : "Robert Ransbottom",
+ "y" : 2
+ },
+ {
+ "drilldown" : "Roger Bell_West",
+ "name" : "Roger Bell_West",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Simon Green",
+ "name" : "Simon Green",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Thomas Kohler",
+ "name" : "Thomas Kohler",
+ "y" : 4
+ },
+ {
+ "drilldown" : "Ulrich Rieke",
+ "name" : "Ulrich Rieke",
+ "y" : 4
+ },
+ {
+ "drilldown" : "Vinod Kumar K",
+ "name" : "Vinod Kumar K",
+ "y" : 3
+ },
+ {
+ "drilldown" : "W. Luis Mochan",
+ "name" : "W. Luis Mochan",
+ "y" : 3
+ },
+ {
+ "drilldown" : "Wanderdoc",
+ "name" : "Wanderdoc",
+ "y" : 2
+ }
+ ],
+ "name" : "The Weekly Challenge - 345"
+ }
+ ],
+ "subtitle" : {
+ "text" : "[Champions: 30] Last updated at 2025-11-03 16:24:29 GMT"
+ },
+ "title" : {
+ "text" : "The Weekly Challenge - 345"
+ },
+ "tooltip" : {
+ "followPointer" : 1,
+ "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>",
+ "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>"
+ },
+ "xAxis" : {
+ "type" : "category"
+ },
+ "yAxis" : {
+ "title" : {
+ "text" : "Total Solutions"
+ }
+ }
+}
diff --git a/stats/pwc-current.json b/stats/pwc-current.json
index e55f2c2439..c41752d639 100644
--- a/stats/pwc-current.json
+++ b/stats/pwc-current.json
@@ -9,20 +9,6 @@
[
"Perl",
2
- ],
- [
- "Blog",
- 1
- ]
- ],
- "id" : "Ali Moradi",
- "name" : "Ali Moradi"
- },
- {
- "data" : [
- [
- "Perl",
- 2
]
],
"id" : "Andreas Mahnke",
@@ -31,78 +17,6 @@
{
"data" : [
[
- "Raku",
- 2
- ]
- ],
- "id" : "Andrew Shitov",
- "name" : "Andrew Shitov"
- },
- {
- "data" : [
- [
- "Raku",
- 2
- ],
- [
- "Blog",
- 1
- ]
- ],
- "id" : "Arne Sommer",
- "name" : "Arne Sommer"
- },
- {
- "data" : [
- [
- "Perl",
- 2
- ],
- [
- "Raku",
- 2
- ]
- ],
- "id" : "Athanasius",
- "name" : "Athanasius"
- },
- {
- "data" : [
- [
- "Raku",
- 1
- ]
- ],
- "id" : "BarrOff",
- "name" : "BarrOff"
- },
- {
- "data" : [
- [
- "Perl",
- 2
- ],
- [
- "Blog",
- 1
- ]
- ],
- "id" : "Bob Lied",
- "name" : "Bob Lied"
- },
- {
- "data" : [
- [
- "Perl",
- 2
- ]
- ],
- "id" : "David Ferrone",
- "name" : "David Ferrone"
- },
- {
- "data" : [
- [
"Perl",
2
]
@@ -113,58 +27,6 @@
{
"data" : [
[
- "Raku",
- 2
- ]
- ],
- "id" : "Feng Chang",
- "name" : "Feng Chang"
- },
- {
- "data" : [
- [