diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-11-24 14:48:02 +0000 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-11-24 14:48:02 +0000 |
| commit | 2d11842284e2c5fdab012d81a282d6b466f72572 (patch) | |
| tree | a04a4443c6d432dd539d1ebce65738f37377d12b | |
| parent | b64b97c214120ddd79c9d1fced238e971424a913 (diff) | |
| download | perlweeklychallenge-club-2d11842284e2c5fdab012d81a282d6b466f72572.tar.gz perlweeklychallenge-club-2d11842284e2c5fdab012d81a282d6b466f72572.tar.bz2 perlweeklychallenge-club-2d11842284e2c5fdab012d81a282d6b466f72572.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Mohammad Sajid Anwar.
- Added solutions by Andrew Shitov.
- Added solutions by Niels van Dijke.
- Added solutions by Wanderdoc.
- Added solutions by Andreas Mahnke.
- Added solutions by Mark Anderson.
- Added solutions by Kjetil Skotheim.
- Added solutions by Luca Ferrari.
31 files changed, 813 insertions, 469 deletions
diff --git a/challenge-349/eric-cheung/python/ch-1.py b/challenge-349/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..c40018e582 --- /dev/null +++ b/challenge-349/eric-cheung/python/ch-1.py @@ -0,0 +1,23 @@ +
+## strInput = "textbook" ## Example 1
+## strInput = "aaaaa" ## Example 2
+## strInput = "hoorayyy" ## Example 3
+## strInput = "x" ## Example 4
+strInput = "aabcccddeeffffghijjk" ## Example 5
+
+strTemp = strInput[0]
+arrOutput = []
+
+nIndx = 1
+while nIndx < len(strInput):
+ if strInput[nIndx] == strTemp[-1]:
+ strTemp = strTemp + strInput[nIndx]
+ else:
+ arrOutput.append(strTemp)
+ strTemp = strInput[nIndx]
+
+ nIndx = nIndx + 1
+
+arrOutput.append(strTemp)
+
+print (max([len(strLoop) for strLoop in arrOutput]))
diff --git a/challenge-349/eric-cheung/python/ch-2.py b/challenge-349/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a0cc089fec --- /dev/null +++ b/challenge-349/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ +
+## strPath = "ULD" ## Example 1
+## strPath = "ULDR" ## Example 2
+## strPath = "UUURRRDDD" ## Example 3
+## strPath = "UURRRDDLLL" ## Example 4
+strPath = "RRUULLDDRRUU" ## Example 5
+
+nX = 0
+nY = 0
+
+for charLoop in strPath:
+ nX = nX + (-1 if charLoop == "L" else 1 if charLoop == "R" else 0)
+ nY = nY + (-1 if charLoop == "D" else 1 if charLoop == "U" else 0)
+
+print (nX == 0 and nY == 0)
diff --git a/challenge-349/mohammad-anwar/perl/ch-1.pl b/challenge-349/mohammad-anwar/perl/ch-1.pl new file mode 100644 index 0000000000..92f7dcafac --- /dev/null +++ b/challenge-349/mohammad-anwar/perl/ch-1.pl @@ -0,0 +1,37 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; + +my @examples = ( + { in => "textbook" , exp => 2 }, + { in => "aaaaa" , exp => 5 }, + { in => "hoorayyy" , exp => 3 }, + { in => "x" , exp => 1 }, + { in => "aabcccddeeffffghijjk", exp => 4 }, +); + +is(power_string($_->{in}), $_->{exp}) for @examples; + +done_testing; + +sub power_string { + my ($s) = @_; + return 0 unless length $s; + + my $max = 1; + my $count = 1; + + for my $i (1 .. length($s)-1) { + if (substr($s,$i,1) eq substr($s,$i-1,1)) { + $count++; + } else { + $max = $count if $count > $max; + $count = 1; + } + } + + $max = $count if $count > $max; + return $max; +} diff --git a/challenge-349/mohammad-anwar/python/ch-1.py b/challenge-349/mohammad-anwar/python/ch-1.py new file mode 100644 index 0000000000..6ae3d30260 --- /dev/null +++ b/challenge-349/mohammad-anwar/python/ch-1.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +def power_string(s: str) -> int: + if len(s) == 0: + return 0 + + max_len = 1 + count = 1 + + for i in range(1, len(s)): + if s[i] == s[i-1]: + count += 1 + else: + if count > max_len: + max_len = count + count = 1 + + if count > max_len: + max_len = count + + return max_len + + +examples = [ + {'in': "textbook" , 'exp': 2}, + {'in': "aaaaa" , 'exp': 5}, + {'in': "hoorayyy" , 'exp': 3}, + {'in': "x" , 'exp': 1}, + {'in': "aabcccddeeffffghijjk", 'exp': 4}, +] + +for idx, ex in enumerate(examples, 1): + result = power_string(ex['in']) + assert result == ex['exp'] + +print("All tests passed.") diff --git a/challenge-349/mohammad-anwar/raku/ch-1.raku b/challenge-349/mohammad-anwar/raku/ch-1.raku new file mode 100644 index 0000000000..1c4541bba8 --- /dev/null +++ b/challenge-349/mohammad-anwar/raku/ch-1.raku @@ -0,0 +1,34 @@ +#!/usr/bin/env raku + +use Test; + +my @examples = ( + { in => "textbook" , exp => 2 }, + { in => "aaaaa" , exp => 5 }, + { in => "hoorayyy" , exp => 3 }, + { in => "x" , exp => 1 }, + { in => "aabcccddeeffffghijjk", exp => 4 }, +); + +for @examples -> $ex { + is power_string($ex<in>), $ex<exp>; +} + +sub power_string(Str $s) { + return 0 if $s.chars == 0; + + my $max = 1; + my $count = 1; + + for 1 ..^ $s.chars -> $i { + if $s.substr($i,1) eq $s.substr($i-1,1) { + $count++; + } else { + $max = $count if $count > $max; + $count = 1; + } + } + + $max = $count if $count > $max; + return $max; +} diff --git a/challenge-349/perlboy1967/perl/ch1.pl b/challenge-349/perlboy1967/perl/ch-1.pl index 61f9803abc..61f9803abc 100755 --- a/challenge-349/perlboy1967/perl/ch1.pl +++ b/challenge-349/perlboy1967/perl/ch-1.pl diff --git a/challenge-349/perlboy1967/perl/ch2.pl b/challenge-349/perlboy1967/perl/ch-2.pl index 98ba31ac6a..98ba31ac6a 100755 --- a/challenge-349/perlboy1967/perl/ch2.pl +++ b/challenge-349/perlboy1967/perl/ch-2.pl diff --git a/stats/pwc-challenge-348.json b/stats/pwc-challenge-348.json new file mode 100644 index 0000000000..c36587a120 --- /dev/null +++ b/stats/pwc-challenge-348.json @@ -0,0 +1,563 @@ +{ + "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", + 1 + ] + ], + "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" : [ + [ + "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 + ], + [ + "Blog", + 10 + ] + ], + "id" : "Luca Ferrari", + "name" : "Luca Ferrari" + }, + { + "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 + ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, + { + "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" : [ + [ + "Perl", + 2 + ], + [ + "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" : "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" : 1 + }, + { + "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" : "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" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 12 + }, + { + "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" : "Niels van Dijke", + "name" : "Niels van Dijke", + "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" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 5 + }, + { + "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" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + }, + { + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc", + "y" : 2 + } + ], + "name" : "The Weekly Challenge - 348" + } + ], + "subtitle" : { + "text" : "[Champions: 29] Last updated at 2025-11-24 14:47:43 GMT" + }, + "title" : { + "text" : "The Weekly Challenge - 348" + }, + "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 8ed04396d2..604cf0a632 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", @@ -32,7 +18,7 @@ "data" : [ [ "Raku", - 1 + 2 ] ], "id" : "Andrew Shitov", @@ -41,110 +27,6 @@ { "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" : [ - [ - "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 ] @@ -155,16 +37,6 @@ { "data" : [ [ - "Perl", - 2 - ] - ], - "id" : "Lubos Kolouch", - "name" : "Lubos Kolouch" - }, - { - "data" : [ - [ "Raku", 2 ], @@ -190,30 +62,6 @@ "data" : [ [ "Perl", - 2 - ] - ], - "id" : "Matthew Neleigh", - "name" : "Matthew Neleigh" - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ], - "id" : "Matthias Muth", - "name" : "Matthias Muth" - }, - { - "data" : [ - [ - |
