diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-27 12:30:09 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-05-27 12:30:09 +0100 |
| commit | 121b188ff9875f14ddd1567ad62ceb734d1ed226 (patch) | |
| tree | c17558bc57c5f1509a29016c8a94c841452292a4 | |
| parent | 72abeccd330b38f170d2f8b46692408519f27289 (diff) | |
| download | perlweeklychallenge-club-121b188ff9875f14ddd1567ad62ceb734d1ed226.tar.gz perlweeklychallenge-club-121b188ff9875f14ddd1567ad62ceb734d1ed226.tar.bz2 perlweeklychallenge-club-121b188ff9875f14ddd1567ad62ceb734d1ed226.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Bob Lied.
- Added solutions by David Ferrone.
- Added solutions by Packy Anderson.
- Added solutions by PokGoPun.
- Added solutions by Niels van Dijke.
- Added solutions by Feng Chang.
- Added solutions by Mark Anderson.
- Added solutions by E. Choroba.
- Added solutions by Steven Wilson.
23 files changed, 3755 insertions, 3487 deletions
diff --git a/challenge-270/eric-cheung/python/ch-1.py b/challenge-270/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..d0383836c7 --- /dev/null +++ b/challenge-270/eric-cheung/python/ch-1.py @@ -0,0 +1,25 @@ +
+def IsPosSpecial (arrInput, nRow, nCol):
+ if arrInput[nRow][nCol] == 0:
+ return False
+
+ for nRowLoop in range(len(arrInput)):
+ if nRowLoop == nRow:
+ continue
+ if arrInput[nRowLoop][nCol] == 1:
+ return False
+
+ for nColLoop in range(len(arrInput[0])):
+ if nColLoop == nCol:
+ continue
+ if arrInput[nRow][nColLoop] == 1:
+ return False
+
+ return True
+
+## arrMatrix = [[1, 0, 0], [0, 0, 1], [1, 0, 0]] ## Example 1
+arrMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] ## Example 2
+
+arrOutput = [[nRowIndx, nColIndx] for nRowIndx in range(len(arrMatrix)) for nColIndx in range(len(arrMatrix[0])) if IsPosSpecial (arrMatrix, nRowIndx, nColIndx)]
+
+print (len(arrOutput))
diff --git a/challenge-270/eric-cheung/python/ch-2.py b/challenge-270/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..fdd90ffe3d --- /dev/null +++ b/challenge-270/eric-cheung/python/ch-2.py @@ -0,0 +1,25 @@ +
+nCost = 0
+
+## Example 1
+arrInt = [4, 1]
+nX = 3
+nY = 2
+
+## Example 2
+## arrInt = [2, 3, 3, 3, 5]
+## nX = 2
+## nY = 1
+
+while len(set(arrInt)) > 1:
+ arrInt = sorted(arrInt)
+
+ if len(set(arrInt)) == 2 and arrInt.count(arrInt[0]) == 1:
+ nCost = nCost + nX
+ else:
+ arrInt[1] = arrInt[1] + 1
+ nCost = nCost + nY
+
+ arrInt[0] = arrInt[0] + 1
+
+print (nCost)
diff --git a/challenge-271/eric-cheung/python/ch-1.py b/challenge-271/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..4913afcb8a --- /dev/null +++ b/challenge-271/eric-cheung/python/ch-1.py @@ -0,0 +1,10 @@ +
+import numpy as np
+
+## arrMatrix = [[0, 1], [1, 0]] ## Example 1
+## arrMatrix = [[0, 0, 0], [1, 0, 1]] ## Example 2
+arrMatrix = [[0, 0], [1, 1], [0, 0]] ## Example 3
+
+arrNumOne = [arrMatrix[nLoop].count(1) for nLoop in range(len(arrMatrix))]
+
+print (np.argmax(arrNumOne) + 1)
diff --git a/challenge-271/eric-cheung/python/ch-2.py b/challenge-271/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..847b810677 --- /dev/null +++ b/challenge-271/eric-cheung/python/ch-2.py @@ -0,0 +1,9 @@ +
+## arrInt = [0, 1, 2, 3, 4, 5, 6, 7, 8] ## Example 1
+arrInt = [1024, 512, 256, 128, 64] ## Example 2
+
+arrOrder = [[bin(nElem).replace("0b", "").count("1"), nElem] for nElem in arrInt]
+
+arrOutput = [nElem for strSort, nElem in sorted(arrOrder, key = lambda nElem: (nElem[0], nElem[1]))]
+
+print (arrOutput)
diff --git a/challenge-271/perlboy1967/perl/ch1.pl b/challenge-271/perlboy1967/perl/ch-1.pl index 0e548569b8..0e548569b8 100755 --- a/challenge-271/perlboy1967/perl/ch1.pl +++ b/challenge-271/perlboy1967/perl/ch-1.pl diff --git a/challenge-271/perlboy1967/perl/ch2.pl b/challenge-271/perlboy1967/perl/ch-2.pl index e3c23e9007..e3c23e9007 100755 --- a/challenge-271/perlboy1967/perl/ch2.pl +++ b/challenge-271/perlboy1967/perl/ch-2.pl diff --git a/stats/pwc-challenge-270.json b/stats/pwc-challenge-270.json new file mode 100644 index 0000000000..1ab6e4b33b --- /dev/null +++ b/stats/pwc-challenge-270.json @@ -0,0 +1,574 @@ +{ + "subtitle" : { + "text" : "[Champions: 30] Last updated at 2024-05-27 11:19:38 GMT" + }, + "legend" : { + "enabled" : 0 + }, + "xAxis" : { + "type" : "category" + }, + "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 + }, + "chart" : { + "type" : "column" + }, + "drilldown" : { + "series" : [ + { + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Arne Sommer", + "id" : "Arne Sommer" + }, + { + "id" : "Athanasius", + "name" : "Athanasius", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "BarrOff", + "data" : [ + [ + "Raku", + 1 + ] + ], + "name" : "BarrOff" + }, + { + "id" : "Bob Lied", + "name" : "Bob Lied", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { + "id" : "Bruce Gray", + "name" : "Bruce Gray", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Dave Jacoby", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Dave Jacoby" + }, + { + "id" : "David Ferrone", + "name" : "David Ferrone", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "name" : "E. Choroba", + "data" : [ + [ + "Perl", + 2 + ] + ], + "id" : "E. Choroba" + }, + { + "id" : "Feng Chang", + "name" : "Feng Chang", + "data" : [ + [ + "Raku", + 2 + ] + ] + }, + { + "id" : "Jan Krnavek", + "name" : "Jan Krnavek", + "data" : [ + [ + "Raku", + 1 + ] + ] + }, + { + "name" : "Jorg Sommrey", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Jorg Sommrey" + }, + { + "name" : "Lance Wicks", + "data" : [ + [ + "Perl", + 1 + ] + ], + "id" : "Lance Wicks" + }, + { + "id" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ], + [ + "Blog", + 1 + ] + ] + }, + { + "name" : "Luca Ferrari", + "data" : [ + [ + "Raku", + 2 + ], + [ + "Blog", + 9 + ] + ], + "id" : "Luca Ferrari" + }, + { + "id" : "Mark Anderson", + "name" : "Mark Anderson", + "data" : [ + [ + "Raku", + 1 + ] + ] + }, + { + "data" : [ + [ + "Perl", + 1 + ] + ], + "name" : "Matthew Neleigh", + "id" : "Matthew Neleigh" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Matthias Muth", + "id" : "Matthias Muth" + }, + { + "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" + }, + { + "id" : "Reinier Maliepaard", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "name" : "Reinier Maliepaard" + }, + { + "name" : "Robbie Hatley", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Robbie Hatley" + }, + { + "id" : "Robert Ransbottom", + "data" : [ + [ + "Raku", + 2 + ] + ], + "name" : "Robert Ransbottom" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "Roger Bell_West", + "id" : "Roger Bell_West" + }, + { + "name" : "Simon Green", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Simon Green" + }, + { + "name" : "Thomas Kohler", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 2 + ] + ], + "id" : "Thomas Kohler" + }, + { + "name" : "Ulrich Rieke", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ulrich Rieke" + }, + { + "data" : [ + [ + "Perl", + 2 + ], + [ + "Blog", + 1 + ] + ], + "name" : "W. Luis Mochan", + "id" : "W. Luis Mochan" + } + ] + }, + "title" : { + "text" : "The Weekly Challenge - 270" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "series" : [ + { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 270", + "data" : [ + { + "drilldown" : "Arne Sommer", + "y" : 3, + "name" : "Arne Sommer" + }, + { + "y" : 4, + "drilldown" : "Athanasius", + "name" : "Athanasius" + }, + { + "name" : "BarrOff", + "drilldown" : "BarrOff", + "y" : 1 + }, + { + "y" : 2, + "drilldown" : "Bob Lied", + "name" : "Bob Lied" + }, + { + "name" : "Bruce Gray", + "drilldown" : "Bruce Gray", + "y" : 2 + }, + { + "name" : "Dave Jacoby", + "drilldown" : "Dave Jacoby", + "y" : 3 + }, + { + "name" : "David Ferrone", + "drilldown" : "David Ferrone", + "y" : 1 + }, + { + "name" : "E. Choroba", + "y" : 2, + "drilldown" : "E. Choroba" + }, + { + "name" : "Feng Chang", + "y" : 2, + "drilldown" : "Feng Chang" + }, + { + "name" : "Jan Krnavek", + "y" : 1, + "drilldown" : "Jan Krnavek" + }, + { + "name" : "Jorg Sommrey", + "drilldown" : "Jorg Sommrey", + "y" : 3 + }, + { + "name" : "Lance Wicks", + "drilldown" : "Lance Wicks", + "y" : 1 + }, + { + "name" : "Laurent Rosenfeld", + "y" : 3, + "drilldown" : "Laurent Rosenfeld" + }, + { + "drilldown" : "Luca Ferrari", + "y" : 11, + "name" : "Luca Ferrari" + }, + { + "y" : 1, + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson" + }, + { + "name" : "Matthew Neleigh", + "y" : 1, + "drilldown" : "Matthew Neleigh" + }, + { + "drilldown" : "Matthias Muth", + "y" : 3, + "name" : "Matthias Muth" + }, + { + "drilldown" : "Nelo Tovar", + "y" : 2, + "name" : "Nelo Tovar" + }, + { + "drilldown" : "Niels van Dijke", + "y" : 2, + "name" : "Niels van Dijke" + }, + { + "name" : "Packy Anderson", + "y" : 5, + "drilldown" : "Packy Anderson" + }, + { + "drilldown" : "Peter Campbell Smith", + "y" : 3, + "name" : "Peter Campbell Smith" + }, + { + "name" : "Peter Meszaros", + "y" : 2, + "drilldown" : "Peter Meszaros" + }, + { + "name" : "Reinier Maliepaard", + "y" : 4, + "drilldown" : "Reinier Maliepaard" + }, + { + "name" : "Robbie Hatley", + "y" : 2, + "drilldown" : "Robbie Hatley" + }, + { + "drilldown" : "Robert Ransbottom", + "y" : 2, + "name" : "Robert Ransbottom" + }, + { + "y" : 5, + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West" + }, + { + "y" : 3, + "drilldown" : "Simon Green", + "name" : "Simon Green" + }, + { + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler", + "y" : 4 + }, + { + "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", + "y" : 4 + }, + { + "drilldown" : "W. Luis Mochan", + "y" : 3, + "name" : "W. Luis Mochan" + } + ] + } + ] +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 55bc5c0ec4..242f5d4a03 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,506 +1,108 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, - "chart" : { - "type" : "column" - }, - "legend" : { - "enabled" : 0 - }, - "series" : [ - { - "name" : "The Weekly Challenge - 270", - "colorByPoint" : 1, - "data" : [ - { - "name" : "Arne Sommer", - "y" : 3, - "drilldown" : "Arne Sommer" - }, - { - "drilldown" : "Athanasius", - "name" : "Athanasius", - "y" : 4 - }, - { - "drilldown" : "BarrOff", - "name" : "BarrOff", - "y" : 1 - }, - { - "y" : 2, - "name" : "Bruce Gray", - "drilldown" : "Bruce Gray" - }, - { - "name" : "Dave Jacoby", - "y" : 3, - "drilldown" : "Dave Jacoby" - }, - { - "drilldown" : "David Ferrone", - "y" : 1, - "name" : "David Ferrone" - }, - { - "name" : "Jan Krnavek", - "y" : 1, - "drilldown" : "Jan Krnavek" - }, - { - "y" : 3, - "name" : "Jorg Sommrey", - "drilldown" : "Jorg Sommrey" - }, - { - "drilldown" : "Lance Wicks", - "name" : "Lance Wicks", - "y" : 1 - }, - { - "name" : "Laurent Rosenfeld", - "y" : 3, - "drilldown" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Luca Ferrari", - "y" : 11, - "name" : "Luca Ferrari" - }, - { - "drilldown" : "Mark Anderson", - "y" : 1, - "name" : "Mark Anderson" - }, - { - "name" : "Matthew Neleigh", - "y" : 1, - "drilldown" : "Matthew Neleigh" - }, - { - "y" : 3, - "name" : "Matthias Muth", - "drilldown" : "Matthias Muth" - }, - { - "name" : "Nelo Tovar", - "y" : 2, - "drilldown" : "Nelo Tovar" - }, - { - "drilldown" : "Niels van Dijke", - "name" : "Niels van Dijke", - "y" : 2 - }, - { - "drilldown" : "Peter Campbell Smith", - "name" : "Peter Campbell Smith", - "y" : 3 - }, - { - "y" : 2, - "name" : "Peter Meszaros", - "drilldown" : "Peter Meszaros" - }, - { - "drilldown" : "Reinier Maliepaard", - "y" : 4, - "name" : "Reinier Maliepaard" - }, - { - "drilldown" : "Robbie Hatley", - "y" : 2, - "name" : "Robbie Hatley" - }, - { - "drilldown" : "Robert Ransbottom", - "y" : 2, - "name" : "Robert Ransbottom" - }, - { - "y" : 5, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" - }, - { - "y" : 3, - "name" : "Simon Green", - "drilldown" : "Simon Green" - }, - { - "y" : 4, - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler" - }, - { - "y" : 4, - "name" : "Ulrich Rieke", - "drilldown" : "Ulrich Rieke" - }, - { - "name" : "W. Luis Mochan", - "y" : 3, - "drilldown" : "W. Luis Mochan" - } - ] - } - ], - "xAxis" : { - "type" : "category" - }, "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", "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" + }, "title" : { - "text" : "The Weekly Challenge - 270" + "text" : "The Weekly Challenge - 271" }, "drilldown" : { "series" : [ { - "name" : "Arne Sommer", - "id" : "Arne Sommer", - "data" : [ - [ - "Raku", - 2 - ], - [ - "Blog", - 1 - ] - ] - }, - { - "name" : "Athanasius", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Raku", - 2 - ] - ], - "id" : "Athanasius" - }, - { - "data" : [ - [ - "Raku", - 1 - ] - ], - "id" : "BarrOff", - "name" : "BarrOff" - }, - { - "name" : "Bruce Gray", - "data" : [ - [ - "Raku", - 2 - ] - ], - "id" : "Bruce Gray" - }, - { - "name" : "Dave Jacoby", - "id" : "Dave Jacoby", - "data" : [ - [ - "Perl", - 2 - ], - [ - "Blog", - 1 - ] - ] - }, - { - "data" : [ - [ - "Perl", - 1 - ] - ], + "name" : "David Ferrone", "id" : "David Ferrone", - "name" : "David Ferrone" - }, - { - "id" : "Jan Krnavek", - "data" : [ - [ - "Raku", - 1 - ] - ], - "name" : "Jan Krnavek" - }, - { "data" : [ [ "Perl", 2 - ], - [ - "Blog", - 1 - ] - ], - "id" : "Jorg Sommrey", - "name" : "Jorg Sommrey" - }, - { - "id" : "Lance Wicks", - "data" : [ - [ - "Perl", - 1 - ] - ], - "name" : "Lance Wicks" - }, - { - "data" : [ - [ - "Perl", - 1 - ], - [ - "Raku", - 1 - ], - [ - "Blog", - 1 ] - ], - "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" + ] }, { - "name" : "Luca Ferrari", + "name" : "Feng Chang", + "id" : "Feng Chang", "data" : [ [ "Raku", 2 - ], - [ - "Blog", - 9 ] - ], - "id" : "Luca Ferrari" + ] }, { + "id" : "Mark Anderson", "name" : "M |
