diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-08 19:15:36 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-08 19:15:36 +0000 |
| commit | da0d5dcf50f8fa8def91abaafce1fd5624ec1a61 (patch) | |
| tree | 48d62d167588ce05b7ad7e5e2b321355d81a3f0f | |
| parent | 066a38cc3004d179463b4c3cd5feb18b042ad36f (diff) | |
| download | perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.gz perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.bz2 perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.zip | |
i- Added solutions by Mark Anderson.
- Added solutions by PokGoPun.
- Added solutions by Simon Proctor.
- Added solutions by Luca Ferrari.
- Added solutions by Thomas Kohler.
- Added solutions by Peter Campbell Smith.
- Added solutions by Niels van Dijke.
- Added solutions by W. Luis Mochan.
- Added solutions by David Ferrone.
- Added solutions by Dave Jacoby.
- Added solutions by Peter Meszaros.
- Added solutions by Laurent Rosenfeld.
24 files changed, 2769 insertions, 2462 deletions
diff --git a/challenge-250/eric-cheung/python/ch-1.py b/challenge-250/eric-cheung/python/ch-1.py index 3f0e3c37c1..66f88a07e9 100755 --- a/challenge-250/eric-cheung/python/ch-1.py +++ b/challenge-250/eric-cheung/python/ch-1.py @@ -1,10 +1,17 @@ -## arrInt = [0, 1, 2] ## Example 1
-## arrInt = [4, 3, 2, 1] ## Example 2
-arrInt = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] ## Example 3
-
-arrOutput = [nIndx for nIndx in range(len(arrInt)) if nIndx % 10 == arrInt[nIndx]]
-if len(arrOutput) > 0:
- print (arrOutput[0])
-else:
- print (-1)
+## arrInt = [6, 12, 25, 1] ## Example 1
+## arrInt = [10, 7, 31, 5, 2, 2] ## Example 2
+arrInt = [1, 2, 10] ## Example 3
+
+nSum = 0
+while len(arrInt) > 0:
+ if len(arrInt) == 1:
+ nSum = nSum + arrInt[0]
+ del arrInt[0]
+ else:
+ nSum = nSum + int(str(arrInt[0]) + str(arrInt[-1]))
+ del arrInt[-1]
+ del arrInt[0]
+
+print (nSum)
+
diff --git a/challenge-250/eric-cheung/python/ch-2.py b/challenge-250/eric-cheung/python/ch-2.py index 43a7617ff9..a659fab6a6 100755 --- a/challenge-250/eric-cheung/python/ch-2.py +++ b/challenge-250/eric-cheung/python/ch-2.py @@ -1,9 +1,13 @@ -def GetAlphaNumLen (strInput):
- return int(strInput) if strInput.isnumeric() else len(strInput)
+## Remarks
+## https://github.com/doocs/leetcode/blob/main/solution/1300-1399/1380.Lucky%20Numbers%20in%20a%20Matrix/README_EN.md
-## arrAlphaNumStr = ["perl", "2", "000", "python", "r4ku"] ## Example 1
-arrAlphaNumStr = ["001", "1", "000", "0001"] ## Example 2
+## arrMatrix = [[3, 7, 8], [9, 11, 13], [15, 16, 17]] ## Example 1
+## arrMatrix = [[1, 10, 4, 2], [9, 3, 8, 7], [15, 16, 17, 12]] ## Example 2
+arrMatrix = [[7, 8], [1, 2]] ## Example 3
-arrOutput = [GetAlphaNumLen(strLoop) for strLoop in arrAlphaNumStr]
-print (max(arrOutput))
+setRowMin = {min(rowLoop) for rowLoop in arrMatrix}
+setColMax = {max(colLoop) for colLoop in zip(*arrMatrix)}
+
+arrLuckyNum = list(setRowMin & setColMax) ## Intersection of Two Sets
+print (arrLuckyNum if len(arrLuckyNum) > 0 else -1)
diff --git a/challenge-251/laurent-rosenfeld/blog.txt b/challenge-251/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..312e6abc5b --- /dev/null +++ b/challenge-251/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +https://blogs.perl.org/users/laurent_r/2024/01/perl-weekly-challenge-251-concatenation-value.html diff --git a/challenge-251/laurent-rosenfeld/perl/ch-1.pl b/challenge-251/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..8ff2ab1549 --- /dev/null +++ b/challenge-251/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,18 @@ +use strict; +use warnings; +use feature 'say'; + +sub concat_vals { + my @in = @_; + my $concat; + while (@in > 1) { + $concat += (shift @in) . (pop @in); + } + $concat += shift @in if @in > 0; # if we have 1 item left + return $concat; +} + +for my $test ([<6 12 25 1>], [<10 7 31 5 2 2>], [<1 2 10>]) { + printf "%-15s => ", "@$test"; + say concat_vals @$test; +} diff --git a/challenge-251/laurent-rosenfeld/raku/ch-1.raku b/challenge-251/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..341957a396 --- /dev/null +++ b/challenge-251/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,13 @@ +sub concat-vals (@in is copy) { + my $concat; + while @in.elems > 1 { + $concat += @in.shift ~ @in.pop; + } + $concat += shift @in if @in.elems > 0; # last item if any + return $concat; +} + +for <6 12 25 1>, <10 7 31 5 2 2>, <1 2 10> -> @test { + printf "%-15s => ", "@test[]"; + say concat-vals @test; +} diff --git a/challenge-251/perlboy1967/perl/ch1.pl b/challenge-251/perlboy1967/perl/ch-1.pl index 57f97135fc..57f97135fc 100755 --- a/challenge-251/perlboy1967/perl/ch1.pl +++ b/challenge-251/perlboy1967/perl/ch-1.pl diff --git a/challenge-251/perlboy1967/perl/ch2.pl b/challenge-251/perlboy1967/perl/ch-2.pl index 60cd0517ed..60cd0517ed 100755 --- a/challenge-251/perlboy1967/perl/ch2.pl +++ b/challenge-251/perlboy1967/perl/ch-2.pl diff --git a/stats/pwc-challenge-250.json b/stats/pwc-challenge-250.json new file mode 100644 index 0000000000..f31e242126 --- /dev/null +++ b/stats/pwc-challenge-250.json @@ -0,0 +1,677 @@ +{ + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "subtitle" : { + "text" : "[Champions: 35] Last updated at 2024-01-08 19:02:16 GMT" + }, + "drilldown" : { + "series" : [ + { + "name" : "Adam Russell", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Adam Russell" + }, + { + "id" : "Ali Moradi", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Ali Moradi" + }, + { + "id" : "Arne Sommer", + "name" : "Arne Sommer", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Athanasius", + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "name" : "BarrOff", + "id" : "BarrOff" + }, + { + "id" : "Bob Lied", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Bob Lied" + }, + { + "id" : "Bruce Gray", + "name" : "Bruce Gray", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Cheok-Yin Fung", + "id" : "Cheok-Yin Fung" + }, + { + "id" : "Dave Jacoby", + "name" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "David Ferrone", + "name" : "David Ferrone", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "E. Choroba", + "id" : "E. Choroba" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Jaldhar H. Vyas", + "id" : "Jaldhar H. Vyas" + }, + { + "name" : "Jan Krnavek", + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Jan Krnavek" + }, + { + "id" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Jorg Sommrey" + }, + { + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Laurent Rosenfeld" + }, + { + "name" : "Lubos Kolouch", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Lubos Kolouch" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 8 + ] + ], + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" + }, + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 2 + ] + ], + "name" : "Mark Anderson", + "id" : "Mark Anderson" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Matthew Neleigh", + "id" : "Matthew Neleigh" + }, + { + "id" : "Mustafa Aydin", + "name" : "Mustafa Aydin", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Nelo Tovar", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Nelo Tovar" + }, + { + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Niels van Dijke", + "id" : "Niels van Dijke" + }, + { + "id" : "Packy Anderson", + "name" : "Packy Anderson", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Peter Meszaros", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "Peter Meszaros" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Robbie Hatley", + "id" : "Robbie Hatley" + }, + { + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Robert Ransbottom", + "id" : "Robert Ransbottom" + }, + { + "name" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Roger Bell_West" + }, + { + "id" : "Simon Green", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Simon Green" + }, + { + "name" : "Simon Proctor", + "data" : [ + [ + "Raku", + 2 + ] + ], + "id" : "Simon Proctor" + }, + { + "id" : "Solathian", + "data" : [ + [ + "Perl", + 2 + ] + ], + "name" : "Solathian" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Stephen G. Lynn", + "id" : "Stephen G. Lynn" + }, + { + "name" : "Thomas Kohler", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Thomas Kohler" + }, + { + "id" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "name" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan" + } + ] + }, + "legend" : { + "enabled" : 0 + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "followPointer" : 1, + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" + }, + "title" : { + "text" : "The Weekly Challenge - 250" + }, + "series" : [ + { + "colorByPoint" : 1, + "data" : [ + { + "name" : "Adam Russell", + "y" : 2, + "drilldown" : "Adam Russell" + }, + { + "drilldown" : "Ali Moradi", + "y" : 5, + "name" : "Ali Moradi" + }, + { + "name" : "Arne Sommer", + "y" : 3, + "drilldown" : "Arne Sommer" + }, + { + "name" : "Athanasius", + "y" : 4, + "drilldown" : "Athanasius" + }, + { + "y" : 4, + "name" : "BarrOff", + "drilldown" : "BarrOff" + }, + { + "drilldown" : "Bob Lied", + "name" : "Bob Lied", + "y" : 2 + }, + { + "y" : 2, + "name" : "Bruce Gray", + "drilldown" : "Bruce Gray" + }, + { + "y" : 2, + "name" : "Cheok-Yin Fung", + "drilldown" : "Cheok-Yin Fung" + }, + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Jaldhar H. Vyas", + "y" : 5, + "name" : "Jaldhar H. Vyas" + }, + { + "y" : 2, + "name" : "Jan Krnavek", + "drilldown" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "y" : 3, + "drilldown" : "Jorg Sommrey" + }, + { + "name" : "Laurent Rosenfeld", + "y" : 6, + "drilldown" : "Laurent Rosenfeld" + }, + { + "name" : "Lubos Kolouch", + "y" : 5, + "drilldown" : "Lubos Kolouch" + }, + { + "name" : "Luca Ferrari", + "y" : 10, + "drilldown" : "Luca Ferrari" + }, + { + "drilldown" : "Mark Anderson", + "y" : 4, + "name" : "Mark Anderson" + }, + { + "name" : "Matthew Neleigh", + "y" : 2, + "drilldown" : "Matthew Neleigh" + }, + { + "name" : "Mustafa Aydin", + "y" : 2, + "drilldown" : "Mustafa Aydin" + }, + { + "y" : 2, + "name" : "Nelo Tovar", + "drilldown" : "Nelo Tovar" + }, + { + "name" : "Niels van Dijke", + "y" : 2, + "drilldown" : "Niels van Dijke" + }, + { + "y" : 5, + "name" : "Packy Anderson", + "drilldown" : "Packy Anderson" + }, + { + "y" : 3, + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith" + }, + { + "name" : "Peter Meszaros", + "y" : 2, + "drilldown" : "Peter Meszaros" + }, + { + "y" : 3, + "name" : "Robbie Hatley", + "drilldown" : "Robbie Hatley" + }, + { + "drilldown" : "Robert Ransbottom", + "name" : "Robert Ransbottom", + "y" : 2 + }, + { + "drilldown" : "Roger Bell_West", + "y" : 5, + "name" : "Roger Bell_West" + }, + { + "y" : 3, + "name" : "Simon Green", + "drilldown" : "Simon Green" + }, + { + "name" : "Simon Proctor", + "y" : 2, + "drilldown" : "Simon Proctor" + }, + { + "y" : 2, + "name" : "Solathian", + "drilldown" : "Solathian" + }, + { + "drilldown" : "Stephen G. Lynn", + "y" : 3, + "name" : "Stephen G. Lynn" + }, + { + "drilldown" : "Thomas Kohler", + "y" : 4, + "name" : "Thomas Kohler" + }, + { + "name" : "Ulrich Rieke", + "y" : 4, + "drilldown" : "Ulrich Rieke" + }, + { + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan", + "y" : 3 + } + ], + "name" : "The Weekly Challenge - 250" + } + ], + "xAxis" : { + "type" : "category" + } +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index c508065653..4a35b7d705 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,220 +1,122 @@ { + "subtitle" : { + "text" : "[Champions: 11] Last updated at 2024-01-08 19:11:43 GMT" + }, + "tooltip" : { + "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/>", + "followPointer" : 1 + }, + "series" : [ + { + "name" : "The Weekly Challenge - 251", + "data" : [ + { + "drilldown" : "Dave Jacoby", + "name" : "Dave Jacoby", + "y" : 3 + }, + { + "y" : 2, + "name" : "David Ferrone", + "drilldown" : "David Ferrone" + }, + { + "name" : "Laurent Rosenfeld", + "y" : 3, + "drilldown" : "Laurent Rosenfeld" + }, + { + "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", + "y" : 10 + }, + { + "y" : 2, + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" + }, + { + "y" : 2, + "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke" + }, + { + "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", + "y" : 3 + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 + }, + { + "y" : 2, + "name" : "Simon Proctor", + "drilldown" : "Simon Proctor" + }, + { + "drilldown" : "Thomas Kohler", + "y" : 4, + "name" : "Thomas Kohler" + }, + { + "name" : "W. Luis Mochan", + "y" : 3, + "drilldown" : "W. Luis Mochan" + } + ], + "colorByPoint" : 1 + } + ], "drilldown" : { "series" : [ { - "name" : "Adam Russell", "data" : [ [ "Perl", 2 - ] - ], - "id" : "Adam Russell" - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ], - "id" : "Ali Moradi", - "name" : "Ali Moradi" - }, - { - "data" : [ - [ - "Raku", - 2 ], [ "Blog", 1 ] ], - "id" : "Arne Sommer", - "name" : "Arne Sommer" - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ], - "id" : "Athanasius", - "name" : "Athanasius" - }, - { - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ], - "id" : "BarrOff", - "name" : "BarrOff" - }, - { - "name" : "Bob Lied", - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Bob Lied" - }, - { - "data" : [ - [ - "Raku", - 2 - ] - ], - "id" : "Bruce Gray", - "name" : "Bruce Gray" - }, - { - "name" : "Cheok-Yin Fung", - "data" : [ - [ - "Perl", - 2 - ] - ], - "id" : "Cheok-Yin Fung" |
