diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-05-27 01:11:25 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-05-27 01:11:25 +0100 |
| commit | e755f960534a82c604442bf3d6ac6c3b33dc07dc (patch) | |
| tree | 16195a5fb8d8edb7b5ffa94dd02b2aaaeea06e75 | |
| parent | 5e66b7dbc0a48ff40cf7fc56d2f1a5aac484dc42 (diff) | |
| download | perlweeklychallenge-club-e755f960534a82c604442bf3d6ac6c3b33dc07dc.tar.gz perlweeklychallenge-club-e755f960534a82c604442bf3d6ac6c3b33dc07dc.tar.bz2 perlweeklychallenge-club-e755f960534a82c604442bf3d6ac6c3b33dc07dc.zip | |
- Added solutions by Robert DiCicco.
| -rw-r--r-- | challenge-218/robert-dicicco/python/ch-2.py | 110 | ||||
| -rw-r--r-- | challenge-218/robert-dicicco/raku/ch-2.raku | 120 | ||||
| -rw-r--r-- | stats/pwc-current.json | 272 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 54 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 1400 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 758 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 116 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 50 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 56 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 42 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 100 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 628 |
17 files changed, 2132 insertions, 1902 deletions
diff --git a/challenge-218/robert-dicicco/python/ch-2.py b/challenge-218/robert-dicicco/python/ch-2.py new file mode 100644 index 0000000000..20be6643f2 --- /dev/null +++ b/challenge-218/robert-dicicco/python/ch-2.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +#--------------------------------------------- +# AUTHOR: Robert DiCicco +# DATE : 2023-05-26 +# Challenge 218 MatrixScore.py ( Python ) +#--------------------------------------------- +matrix = [ [0,0,1,1], + [1,0,1,0], + [1,1,0,0], ] +row = 0 +col = 0 + +def ShowMatrix(): + total = 0 + for x in range(3): #[0,1,2]: + print(matrix[x]) + total += binary_to_decimal(matrix[x]) + print("Total = ",total,"\n") + +def ToggleRow(r, ov): + cnt = 0 + testmat = [] + for x in matrix[r]: + if x == 0: + testmat.append(1) + else: + testmat.append(0) + cnt += 1 + testval = binary_to_decimal(testmat) + cnt = 0 + if testval > ov: + for x in matrix[r]: + if x == 0: + matrix[r][cnt] = 1 + else: + matrix[r][cnt] = 0 + cnt += 1 + print("Toggled Row ",r) + ShowMatrix() + + +def ToggleCol(c): + ov = GetColVal(c) + row = 0 + testmat = [] + while row < 3: + if matrix[row][c] == 0: + testmat.append(1) + else: + testmat.append(0) + row += 1 + testval = binary_to_decimal(testmat) + if testval > ov: + for x in range(3): #[0,1,2]: + matrix[x][c] = testmat[x] + print("Toggled column ",c) + ShowMatrix() + +def binary_to_decimal(binary_array): + decimal = 0 + power = len(binary_array) - 1 + for digit in binary_array: + decimal += digit * (2 ** power) + power -= 1 + return decimal + +def GetColVal(c): + testmat = [] + row = 0 + while row < 3: + testmat.append(matrix[row][c]) + row += 1 + colval = binary_to_decimal(testmat) + return colval + +############################################ +ShowMatrix() +for myrow in range(3): #[0,1,2]: + bd = binary_to_decimal(matrix[myrow]) + ToggleRow(myrow, bd) + +for mycol in range(4): #[0,1,2,3]: + ToggleCol(mycol) + +#--------------------------------------------- +# SAMPLE OUTPUT +# python .\MatrixScore.py +# [0, 0, 1, 1] +# [1, 0, 1, 0] +# [1, 1, 0, 0] +# Total = 25 + +# Toggled Row 0 +# [1, 1, 0, 0] +# [1, 0, 1, 0] +# [1, 1, 0, 0] +# Total = 34 + +# Toggled column 2 +# [1, 1, 1, 0] +# [1, 0, 0, 0] +# [1, 1, 1, 0] +# Total = 36 + +# Toggled column 3 +# [1, 1, 1, 1] +# [1, 0, 0, 1] +# [1, 1, 1, 1] +# Total = 39 +#--------------------------------------------- diff --git a/challenge-218/robert-dicicco/raku/ch-2.raku b/challenge-218/robert-dicicco/raku/ch-2.raku new file mode 100644 index 0000000000..b0b5f50d59 --- /dev/null +++ b/challenge-218/robert-dicicco/raku/ch-2.raku @@ -0,0 +1,120 @@ +#!/usr/bin/env raku +#--------------------------------------------- +# AUTHOR: Robert DiCicco +# DATE : 2023-05-26 +# Challenge 218 MatrixScore.py ( Raku ) +#--------------------------------------------- +use v6; + +my @matrix = [ [0,0,1,1], + [1,0,1,0], + [1,1,0,0], ]; + +sub ShowMatrix() { + my $total = 0; + my $cnt = 0; + while $cnt <= 2 { + say (@matrix[$cnt]); + $total += binary_to_decimal(@matrix[$cnt]); + $cnt++; + } + say "Total = ",$total; + say ""; +} + +sub binary_to_decimal(@binary_array) { + my $decimal = 0; + my $power = @binary_array.elems - 1; + for (@binary_array) -> $digit { + $decimal += $digit * (2 ** $power); + $power -= 1; + } + return $decimal; +} + +sub ToggleRow($r, $ov) { + my @testmat = []; + my $col = 0; + while $col <= 3 { + my $x = @matrix[$r][$col++]; + $x == 0 ?? @testmat.push: 1 !! @testmat.push: 0; + } + my $testval = binary_to_decimal(@testmat); + if $testval > $ov { + say "Toggled row ",$r; + @matrix[$r] = @testmat; + ShowMatrix(); + } +} + +sub ToggleCol($c) { + my $ov = GetColVal($c); + my $row = 0; + my @testmat = []; + my $testval = 0; + while $row < 3 { + @matrix[$row][$c] == 0 ?? @testmat.push: 1 !! @testmat.push: 0; + $row++; + $testval = binary_to_decimal(@testmat); + } + if $testval > $ov { + for 0..3 -> $x { + @matrix[$x][$c] = @testmat[$x]; + } + print("Toggled column ",$c,"\n"); + ShowMatrix(); + } +} + +sub GetColVal($c) { + my @testmat = []; + my $row = 0; + while $row < 3 { + @testmat.push: @matrix[$row][$c]; + $row++; + } + my $colval = binary_to_decimal(@testmat); + return $colval; +} + + +#################################################### +ShowMatrix(); + +for 0..2 -> $myrow { + my $bd = binary_to_decimal(@matrix[$myrow]); + ToggleRow($myrow, $bd); +} + +for (0..3) -> $myrow { + ToggleCol($myrow); +} + +=begin comment +#--------------------------------------------- +SAMPLE OUTPUT +raku .\MatrixScore.rk +[0 0 1 1] +[1 0 1 0] +[1 1 0 0] +Total = 25 + +Toggled row 0 +[1 1 0 0] +[1 0 1 0] +[1 1 0 0] +Total = 34 + +Toggled column 2 +[1 1 1 0] +[1 0 0 0] +[1 1 1 0] +Total = 36 + +Toggled column 3 +[1 1 1 1] +[1 0 0 1] +[1 1 1 1] +Total = 39 +#--------------------------------------------- +=end comment diff --git a/stats/pwc-current.json b/stats/pwc-current.json index f994535375..2f3476628e 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,12 +1,17 @@ { - "subtitle" : { - "text" : "[Champions: 16] Last updated at 2023-05-26 23:51:03 GMT" - }, "yAxis" : { "title" : { "text" : "Total Solutions" } }, + "title" : { + "text" : "The Weekly Challenge - 218" + }, + "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/>" + }, "plotOptions" : { "series" : { "borderWidth" : 0, @@ -16,12 +21,104 @@ } } }, - "chart" : { - "type" : "column" + "legend" : { + "enabled" : 0 + }, + "series" : [ + { + "data" : [ + { + "drilldown" : "Avery Adams", + "name" : "Avery Adams", + "y" : 3 + }, + { + "name" : "David Ferrone", + "drilldown" : "David Ferrone", + "y" : 2 + }, + { + "drilldown" : "E. Choroba", + "name" : "E. Choroba", + "y" : 2 + }, + { + "drilldown" : "Jorg Sommrey", + "name" : "Jorg Sommrey", + "y" : 2 + }, + { + "name" : "Lubos Kolouch", + "drilldown" : "Lubos Kolouch", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Mark Anderson", + "name" : "Mark Anderson" + }, + { + "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke", + "y" : 2 + }, + { + "y" : 2, + "drilldown" : "Paulo Custodio", + "name" : "Paulo Custodio" + }, + { + "name" : "Peter Campbell Smith", + "drilldown" : "Peter Campbell Smith", + "y" : 3 + }, + { + "y" : 3, + "name" : "Robert DiCicco", + "drilldown" : "Robert DiCicco" + }, + { + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 4 + }, + { + "drilldown" : "Stephen G. Lynn", + "name" : "Stephen G. Lynn", + "y" : 3 + }, + { + "drilldown" : "Steven Wilson", + "name" : "Steven Wilson", + "y" : 1 + }, + { + "y" : 4, + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler" + }, + { + "y" : 3, + "drilldown" : "Ulrich Rieke", + "name" : "Ulrich Rieke" + }, + { + "y" : 3, + "drilldown" : "W. Luis Mochan", + "name" : "W. Luis Mochan" + } + ], + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 218" + } + ], + "xAxis" : { + "type" : "category" }, "drilldown" : { "series" : [ { + "id" : "Avery Adams", "data" : [ [ "Perl", @@ -32,8 +129,7 @@ 2 ] ], - "name" : "Avery Adams", - "id" : "Avery Adams" + "name" : "Avery Adams" }, { "data" : [ @@ -46,33 +142,33 @@ "name" : "David Ferrone" }, { + "name" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "name" : "E. Choroba", "id" : "E. Choroba" }, { - "name" : "Jorg Sommrey", "id" : "Jorg Sommrey", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Jorg Sommrey" }, { + "name" : "Lubos Kolouch", "data" : [ [ "Perl", 2 ] ], - "name" : "Lubos Kolouch", "id" : "Lubos Kolouch" }, { @@ -86,27 +182,26 @@ ] }, { + "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] ], - "id" : "Niels van Dijke", - "name" : "Niels van Dijke" + "id" : "Niels van Dijke" }, { - "name" : "Paulo Custodio", "id" : "Paulo Custodio", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Paulo Custodio" }, { - "id" : "Peter Campbell Smith", "name" : "Peter Campbell Smith", "data" : [ [ @@ -117,11 +212,10 @@ "Blog", 1 ] - ] + ], + "id" : "Peter Campbell Smith" }, { - "name" : "Robert DiCicco", - "id" : "Robert DiCicco", "data" : [ [ "Perl", @@ -129,11 +223,15 @@ ], [ "Raku", - 1 + 2 ] - ] + ], + "id" : "Robert DiCicco", + "name" : "Robert DiCicco" }, { + "name" : "Roger Bell_West", + "id" : "Roger Bell_West", "data" : [ [ "Perl", @@ -143,11 +241,10 @@ "Raku", 2 ] - ], - "id" : "Roger Bell_West", - "name" : "Roger Bell_West" + ] }, { + "id" : "Stephen G. Lynn", "data" : [ [ "Perl", @@ -158,18 +255,17 @@ 1 ] ], - "name" : "Stephen G. Lynn", - "id" : "Stephen G. Lynn" + "name" : "Stephen G. Lynn" }, { - "name" : "Steven Wilson", - "id" : "Steven Wilson", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "Steven Wilson", + "name" : "Steven Wilson" }, { "data" : [ @@ -182,11 +278,10 @@ 2 ] ], - "name" : "Thomas Kohler", - "id" : "Thomas Kohler" + "id" : "Thomas Kohler", + "name" : "Thomas Kohler" }, { - "name" : "Ulrich Rieke", "id" : "Ulrich Rieke", "data" : [ [ @@ -197,9 +292,11 @@ "Raku", 1 ] - ] + ], + "name" : "Ulrich Rieke" }, { + "id" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -210,111 +307,14 @@ 1 ] ], - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan" + "name" : "W. Luis Mochan" } ] }, - "legend" : { - "enabled" : 0 - }, - "title" : { - "text" : "The Weekly Challenge - 218" - }, - "xAxis" : { - "type" : "category" - }, - "tooltip" : { - "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>", - "followPointer" : 1, - "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" + "subtitle" : { + "text" : "[Champions: 16] Last updated at 2023-05-27 00:09:13 GMT" }, - "series" : [ - { - "data" : [ - { - "drilldown" : "Avery Adams", - "name" : "Avery Adams", - "y" : 3 - }, - { - "y" : 2, - "drilldown" : "David Ferrone", - "name" : "David Ferrone" - }, - { - "name" : "E. Choroba", - "drilldown" : "E. Choroba", - "y" : 2 - }, - { - "drilldown" : "Jorg Sommrey", - "name" : "Jorg Sommrey", - "y" : 2 - }, - { - "name" : "Lubos Kolouch", - "drilldown" : "Lubos Kolouch", - "y" : 2 - }, - { - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson", - "y" : 2 - }, - { - "name" : "Niels van Dijke", - "drilldown" : "Niels van Dijke", - "y" : 2 - }, - { - "y" : 2, - "name" : "Paulo Custodio", - "drilldown" : "Paulo Custodio" - }, - { - "y" : 3, - "name" : "Peter Campbell Smith", - "drilldown" : "Peter Campbell Smith" - }, - { - "y" : 2, - "name" : "Robert DiCicco", - "drilldown" : "Robert DiCicco" - }, - { - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West", - "y" : 4 - }, - { - "drilldown" : "Stephen G. Lynn", - "name" : "Stephen G. Lynn", - "y" : 3 - }, - { - "y" : 1, - "drilldown" : "Steven Wilson", - "name" : "Steven Wilson" - }, - { - "name" : "Thomas Kohler", - "drilldown" : "Thomas Kohler", - "y" : 4 - }, - { - "drilldown" : "Ulrich Rieke", - "name" : "Ulrich Rieke", - "y" : 3 - }, - { - "drilldown" : "W. Luis Mochan", - "name" : "W. Luis Mochan", - "y" : 3 - } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 218" - } - ] + "chart" : { + "type" : "column" + } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index f8c6586fa5..efa7f8f9b4 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,36 +1,20 @@ { - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "subtitle" : { - "text" : "Last updated at 2023-05-26 23:51:03 GMT" - }, "legend" : { "enabled" : "false" }, - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2023]" - }, - "chart" : { - "type" : "column" - }, "series" : [ { - "name" : "Contributions", "dataLabels" : { - "enabled" : "true", + "align" : "right", + "color" : "#FFFFFF", "y" : 10, - "rotation" : -90, + "enabled" : "true", "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" }, - "align" : "right", "format" : "{point.y:.0f}", - "color" : "#FFFFFF" + "rotation" : -90 }, "data" : [ [ @@ -43,11 +27,30 @@ ], [ "Raku", - 6425 + 6426 ] - ] + ], + "name" : "Contributions" } ], + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2023]" + }, + "yAxis" : { + "min" : 0, + "title" : { + "text" : null + } + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2023-05-27 00:09:13 GMT" + }, + "chart" : { + "type" : "column" + }, "xAxis" : { "labels" : { "style" : { @@ -56,8 +59,5 @@ } }, "type" : "category" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index f68ba99806..52595c82f5 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,19 +1,12 @@ { - "tooltip" : { - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "headerFormat" : "<span style=\"font-size:11px\"></span>", - "followPointer" : "true" - }, - "xAxis" : { - "type" : "category" - }, "series" : [ { + "colorByPoint" : "true", "data" : [ { - "y" : 163, "name" : "#001", - "drilldown" : "001" + "drilldown" : "001", + "y" : 163 }, { "y" : 129, @@ -32,8 +25,8 @@ }, { "y" : 80, - "name" : "#005", - "drilldown" : "005" + "drilldown" : "005", + "name" : "#005" }, { "y" : 61, @@ -46,9 +39,9 @@ "drilldown" : "007" }, { - "y" : 82, + "drilldown" : "008", "name" : "#008", - "drilldown" : "008" + "y" : 82 }, { "y" : 80, @@ -57,18 +50,18 @@ }, { "y" : 69, - "name" : "#010", - "drilldown" : "010" + "drilldown" : "010", + "name" : "#010" }, { - "y" : 89, + "name" : "#011", "drilldown" : "011", - "name" : "#011" + "y" : 89 }, { - "y" : 92, + "name" : "#012", "drilldown" : "012", - "name" : "#012" + "y" : 92 }, { "y" : 87, @@ -77,8 +70,8 @@ }, { "y" : 102, - "drilldown" : "014", - "name" : "#014" + "name" : "#014", + "drilldown" : "014" }, { "drilldown" : "015", @@ -86,8 +79,8 @@ "y" : 101 }, { - "name" : "#016", "drilldown" : "016", + "name" : "#016", "y" : 75 }, { @@ -96,34 +89,34 @@ "name" : "#017" }, { - "name" : "#018", "drilldown" : "018", + "name" : "#018", "y" : 83 }, { "y" : 105, - "drilldown" : "019", - "name" : "#019" + "name" : "#019", + "drilldown" : "019" }, { - "name" : "#020", "drilldown" : "020", + "name" : "#020", "y" : 103 }, { - "drilldown" : "021", + "y" : 74, "name" : "#021", - "y" : 74 + "drilldown" : "021" }, { "y" : 72, - "drilldown" : "022", - "name" : "#022" + "name" : "#022", + "drilldown" : "022" }, { - "y" : 101, + "drilldown" : "023", "name" : "#023", - "drilldown" : "023" + "y" : 101 }, { "name" : "#024", @@ -131,9 +124,9 @@ "y" : 77 }, { - "y" : 62, "drilldown" : "025", - "name" : "#025" + "name" : "#025", + "y" : 62 }, { "name" : "#026", @@ -142,23 +135,23 @@ }, { "y" : 64, - "name" : "#027", - "drilldown" : "027" + "drilldown" : "027", + "name" : "#027" }, { - "y" : 82, + "drilldown" : "028", "name" : "#028", - "drilldown" : "028" + "y" : 82 }, { - "y" : 83, + "name" : "#029", "drilldown" : "029", - "name" : "#029" + "y" : 83 }, { "y" : 121, - "drilldown" : "030", - "name" : "#030" + "name" : "#030", + "drilldown" : "030" }, { "drilldown" : "031", @@ -166,54 +159,54 @@ "y" : 93 }, { - "y" : 98, + "name" : "#032", "drilldown" : "032", - "name" : "#032" + "y" : 98 }, { + "y" : 114, "drilldown" : "033", - "name" : "#033", - "y" : 114 + "name" : "#033" }, { - "y" : 70, + "drilldown" : "034", "name" : "#034", - "drilldown" : "034" + "y" : 70 }, { - "name" : "#035", "drilldown" : "035", + "name" : "#035", "y" : 68 }, { - "y" : 70, + "drilldown" : "036", "name" : "#036", - "drilldown" : "036" + "y" : 70 }, { + "y" : 70, "drilldown" : "037", - "name" : "#037", - "y" : 70 + "name" : "#037" }, { + "y" : 74, "drilldown" : "038", - "name" : "#038", - "y" : 74 + "name" : "#038" }, { - "y" : 68, + "drilldown" : "039", "name" : "#039", - "drilldown" : "039" + "y" : 68 }, { - "name" : "#040", "drilldown" : "040", + "name" : "#040", "y" : 77 }, { + "y" : 80, "drilldown" : "041", - "name" : "#041", - "y" : 80 + "name" : "#041" }, { "name" : "#042", @@ -221,44 +214,44 @@ "y" : 98 }, { - "drilldown" : "043", "name" : "#043", + "drilldown" : "043", "y" : 72 }, { "y" : 90, - "drilldown" : "044", - "name" : "#044" + "name" : "#044", + "drilldown" : "044" }, { - "drilldown" : "045", "name" : "#045", + "drilldown" : "045", "y" : 102 }, { - "y" : 93, "name" : "#046", - "drilldown" : "046" + "drilldown" : "046", + "y" : 93 }, { "y" : 88, - "drilldown" : "047", - "name" : "#047" + "name" : "#047", + "drilldown" : "047" }, { + "y" : 112, "drilldown" : "048", - "name" : "#048", - "y" : 112 + "name" : "#048" }, { - "y" : 93, "name" : "#049", - "drilldown" : "049" + "drilldown" : "049", + "y" : 93 }, { + "y" : 104, "drilldown" : "050", - "name" : "#050", - "y" : 104 + "name" : "#050" }, { "name" : "#051", |
