diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-11-10 19:06:25 +0000 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-11-10 19:06:25 +0000 |
| commit | 2cb74a7aa10c72b7862513e5e320bc29f1d5f55f (patch) | |
| tree | 345edd8396797b727ad5cc3b11c47fab98ff1daa | |
| parent | 5be599acdad30e97714d9b453dc44fc1d1d5b07f (diff) | |
| download | perlweeklychallenge-club-2cb74a7aa10c72b7862513e5e320bc29f1d5f55f.tar.gz perlweeklychallenge-club-2cb74a7aa10c72b7862513e5e320bc29f1d5f55f.tar.bz2 perlweeklychallenge-club-2cb74a7aa10c72b7862513e5e320bc29f1d5f55f.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Mohammad Sajid Anwar.
- Added solutions by E. Choroba.
- Added solutions by Mark Anderson.
- Added solutions by PokGoPun.
- Added solutions by Niels van Dijke.
- Added solutions by David Ferrone.
- Added solutions by Benjamin Andre.
- Added solutions by Peter Campbell Smith.
- Added solutions by Wanderdoc.
36 files changed, 804 insertions, 493 deletions
diff --git a/challenge-345/perlboy1967/perl/ch1.pl b/challenge-345/perlboy1967/perl/ch-1.pl index 891d1f6626..891d1f6626 100755 --- a/challenge-345/perlboy1967/perl/ch1.pl +++ b/challenge-345/perlboy1967/perl/ch-1.pl diff --git a/challenge-345/perlboy1967/perl/ch2.pl b/challenge-345/perlboy1967/perl/ch-2.pl index 1621f26920..1621f26920 100755 --- a/challenge-345/perlboy1967/perl/ch2.pl +++ b/challenge-345/perlboy1967/perl/ch-2.pl diff --git a/challenge-346/perlboy1967/perl/ch1.pl b/challenge-346/perlboy1967/perl/ch-1.pl index aba8ac09e5..aba8ac09e5 100755 --- a/challenge-346/perlboy1967/perl/ch1.pl +++ b/challenge-346/perlboy1967/perl/ch-1.pl diff --git a/challenge-346/perlboy1967/perl/ch2.pl b/challenge-346/perlboy1967/perl/ch-2.pl index 574c7283c8..574c7283c8 100755 --- a/challenge-346/perlboy1967/perl/ch2.pl +++ b/challenge-346/perlboy1967/perl/ch-2.pl diff --git a/challenge-347/eric-cheung/python/ch-1.py b/challenge-347/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..494a0ea2e0 --- /dev/null +++ b/challenge-347/eric-cheung/python/ch-1.py @@ -0,0 +1,16 @@ +
+from datetime import datetime
+from dateutil.parser import parse
+
+## strInputDate = "1st Jan 2025" ## Example 1
+## strInputDate = "22nd Feb 2025" ## Example 2
+## strInputDate = "15th Apr 2025" ## Example 3
+## strInputDate = "23rd Oct 2025" ## Example 4
+strInputDate = "31st Dec 2025" ## Example 5
+
+strOutputDateFormat = "%Y-%m-%d"
+
+objDate = parse(strInputDate)
+
+print (objDate.strftime(strOutputDateFormat))
+
diff --git a/challenge-347/eric-cheung/python/ch-2.py b/challenge-347/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..451bf4727e --- /dev/null +++ b/challenge-347/eric-cheung/python/ch-2.py @@ -0,0 +1,25 @@ +
+## strPhoneNum = "1-23-45-6" ## Example 1
+## strPhoneNum = "1234" ## Example 2
+## strPhoneNum = "12 345-6789" ## Example 3
+## strPhoneNum = "123 4567" ## Example 4
+strPhoneNum = "123 456-78" ## Example 5
+
+strTempPhoneNum = strPhoneNum.replace(" ", "").replace("-", "")
+
+arrPhoneNum = []
+
+while (nLen := len(strTempPhoneNum)) > 0:
+ if nLen <= 3:
+ arrPhoneNum.append(strTempPhoneNum)
+ break
+
+ if nLen == 4:
+ arrPhoneNum.append(strTempPhoneNum[:2])
+ arrPhoneNum.append(strTempPhoneNum[2:])
+ break
+
+ arrPhoneNum.append(strTempPhoneNum[:3])
+ strTempPhoneNum = strTempPhoneNum[3:]
+
+print ("-".join(arrPhoneNum))
diff --git a/challenge-347/mohammad-anwar/perl/ch-1.pl b/challenge-347/mohammad-anwar/perl/ch-1.pl new file mode 100644 index 0000000000..dd080d9a0e --- /dev/null +++ b/challenge-347/mohammad-anwar/perl/ch-1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; + +my @examples = ( + ["1st Jan 2025", "2025-01-01"], + ["22nd Feb 2025", "2025-02-22"], + ["15th Apr 2025", "2025-04-15"], + ["23rd Oct 2025", "2025-10-23"], + ["31st Dec 2025", "2025-12-31"], +); + +is(format_date($_->[0]), $_->[1]) for @examples; + +done_testing; + +sub format_date { + my $str = shift; + $str =~ /(\d+)\w{2} (\w{3}) (\d+)/; + sprintf("%04d-%02d-%02d", $3, 1+index("JanFebMarAprMayJunJulAugSepOctNovDec",$2)/3, $1); +} diff --git a/challenge-347/mohammad-anwar/python/ch-1.py b/challenge-347/mohammad-anwar/python/ch-1.py new file mode 100644 index 0000000000..522239492c --- /dev/null +++ b/challenge-347/mohammad-anwar/python/ch-1.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import re + +def test_format_date(): + examples = [ + ["1st Jan 2025", "2025-01-01"], + ["22nd Feb 2025", "2025-02-22"], + ["15th Apr 2025", "2025-04-15"], + ["23rd Oct 2025", "2025-10-23"], + ["31st Dec 2025", "2025-12-31"], + ] + + for input_str, expected in examples: + result = format_date(input_str) + assert result == expected, f"Expected {expected}, got {result} for input {input_str}" + print("All tests passed!") + +def format_date(date_str): + match = re.search(r'(\d+)\w{2} (\w{3}) (\d+)', date_str) + if match: + day, month, year = match.groups() + month_num = 1 + "JanFebMarAprMayJunJulAugSepOctNovDec".index(month) // 3 + return f"{year}-{month_num:02d}-{int(day):02d}" + return "" + +if __name__ == "__main__": + test_format_date() diff --git a/challenge-347/mohammad-anwar/raku/ch-1.raku b/challenge-347/mohammad-anwar/raku/ch-1.raku new file mode 100644 index 0000000000..caed453736 --- /dev/null +++ b/challenge-347/mohammad-anwar/raku/ch-1.raku @@ -0,0 +1,20 @@ +#!/usr/bin/env raku + +use Test; + +my @examples = ( + ["1st Jan 2025", "2025-01-01"], + ["22nd Feb 2025", "2025-02-22"], + ["15th Apr 2025", "2025-04-15"], + ["23rd Oct 2025", "2025-10-23"], + ["31st Dec 2025", "2025-12-31"], +); + +is(format-date($_[0]), $_[1]) for @examples; + +done-testing; + +sub format-date(Str $str) { + $str ~~ /(\d+) \w**2 \s (\w**3) \s (\d+)/; + sprintf("%04d-%02d-%02d", $2, 1+index("JanFebMarAprMayJunJulAugSepOctNovDec", $1)/3, $0); +} diff --git a/challenge-347/perlboy1967/perl/ch1.pl b/challenge-347/perlboy1967/perl/ch-1.pl index 88a583e9ec..88a583e9ec 100755 --- a/challenge-347/perlboy1967/perl/ch1.pl +++ b/challenge-347/perlboy1967/perl/ch-1.pl diff --git a/challenge-347/perlboy1967/perl/ch2.pl b/challenge-347/perlboy1967/perl/ch-2.pl index 2a0d95021d..2a0d95021d 100755 --- a/challenge-347/perlboy1967/perl/ch2.pl +++ b/challenge-347/perlboy1967/perl/ch-2.pl diff --git a/stats/pwc-challenge-345.json b/stats/pwc-challenge-345.json index 28ff4de607..6b9bf104e8 100644 --- a/stats/pwc-challenge-345.json +++ b/stats/pwc-challenge-345.json @@ -225,6 +225,16 @@ [ "Perl", 2 + ] + ], + "id" : "Niels van Dijke", + "name" : "Niels van Dijke" + }, + { + "data" : [ + [ + "Perl", + 2 ], [ "Raku", @@ -499,6 +509,11 @@ "y" : 2 }, { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { "drilldown" : "Packy Anderson", "name" : "Packy Anderson", "y" : 5 @@ -568,7 +583,7 @@ } ], "subtitle" : { - "text" : "[Champions: 31] Last updated at 2025-11-07 23:55:59 GMT" + "text" : "[Champions: 32] Last updated at 2025-11-10 19:05:27 GMT" }, "title" : { "text" : "The Weekly Challenge - 345" diff --git a/stats/pwc-challenge-346.json b/stats/pwc-challenge-346.json new file mode 100644 index 0000000000..cf34bf7cc3 --- /dev/null +++ b/stats/pwc-challenge-346.json @@ -0,0 +1,566 @@ +{ + "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" : [ + [ + "Perl", + 2 + ] + ], + "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", + 1 + ], + [ + "Blog", + 1 + ] + ], + "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", + 1 + ], + [ + "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 + ] + ], + "id" : "Robbie Hatley", + "name" : "Robbie Hatley" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Robert Ransbottom", + "name" : "Robert Ransbottom" + }, + { + "data" : [ + [ + "Perl", + 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", + 1 + ] + ], + "id" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "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" : 1 + }, + { + "drilldown" : "Arne Sommer", + "name" : "Arne Sommer", + "y" : 3 + }, + { + "drilldown" : "Athanasius", + "name" : "Athanasius", + "y" : 4 + }, + { + "drilldown" : "Bob Lied", + "name" : "Bob Lied", + "y" : 2 + }, + { + "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" : 2 + }, + { + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson", + "y" : 2 + }, + { + "drilldown" : "Matthew Neleigh", + "name" : "Matthew Neleigh", + "y" : 2 + }, + { + "drilldown" : "Matthias Muth", + "name" : "Matthias Muth", + "y" : 2 + }, + { + "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" : 2 + }, + { + "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" : 3 + }, + { + "drilldown" : "Vinod Kumar K", + "name" : "Vinod Kumar K", + "y" : 2 + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + }, + { + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc", + "y" : 2 + } + ], + "name" : "The Weekly Challenge - 346" + } + ], + "subtitle" : { + "text" : "[Champions: 30] Last updated at 2025-11-10 19:05:27 GMT" + }, + "title" : { + "text" : "The Weekly Challenge - 346" + }, + "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 f922990c49..00b9301d23 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -9,78 +9,6 @@ [ "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" - }, - |
