diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-07-26 19:08:33 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2023-07-26 19:08:33 +0100 |
| commit | 5af09e3541ee7a056e1caa1a037ba8e9076d5fc2 (patch) | |
| tree | 508ccf7f15853de1fc183f498e1a103acf38e5ea | |
| parent | c281ebf5f94df784f0b1328acffc244e3baae4a7 (diff) | |
| download | perlweeklychallenge-club-5af09e3541ee7a056e1caa1a037ba8e9076d5fc2.tar.gz perlweeklychallenge-club-5af09e3541ee7a056e1caa1a037ba8e9076d5fc2.tar.bz2 perlweeklychallenge-club-5af09e3541ee7a056e1caa1a037ba8e9076d5fc2.zip | |
- Added solutions by Peter Meszaros.
- Added solutions by Steven Wilson.
- Added solutions by Laurent Rosenfeld.
| -rw-r--r-- | challenge-227/laurent-rosenfeld/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-227/laurent-rosenfeld/perl/ch-1.pl | 19 | ||||
| -rw-r--r-- | challenge-227/laurent-rosenfeld/raku/ch-1.raku | 12 | ||||
| -rw-r--r-- | challenge-227/robert-dicicco/python/ch-2.py | 131 | ||||
| -rw-r--r-- | challenge-227/steven-wilson/perl/ch-1.pl (renamed from challenge-227/steven-wilson/perl/ch-01.pl) | 0 | ||||
| -rw-r--r-- | stats/pwc-current.json | 193 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 78 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 3136 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 398 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 58 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 114 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 30 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 36 |
20 files changed, 2427 insertions, 2211 deletions
diff --git a/challenge-227/laurent-rosenfeld/blog.txt b/challenge-227/laurent-rosenfeld/blog.txt new file mode 100644 index 0000000000..eafff47b85 --- /dev/null +++ b/challenge-227/laurent-rosenfeld/blog.txt @@ -0,0 +1 @@ +https://blogs.perl.org/users/laurent_r/2023/07/perl-weekly-challenge-227-friday-13th.html diff --git a/challenge-227/laurent-rosenfeld/perl/ch-1.pl b/challenge-227/laurent-rosenfeld/perl/ch-1.pl new file mode 100644 index 0000000000..5be4a9450d --- /dev/null +++ b/challenge-227/laurent-rosenfeld/perl/ch-1.pl @@ -0,0 +1,19 @@ +use strict; +use warnings; +use feature 'say'; +use Time::Piece; + +sub friday_13 { + my $year = shift; + my $count = 0; + my $day = 13; + for my $month (1..12) { + my $dt = Time::Piece->strptime("$month/$day/$year", + "%m/%d/%Y"); + $count++ if $dt->wday == 6; # Friday == 6th day + } + return $count; +} +for my $year (2023..2030, 9998) { + say $year, " => ", friday_13 $year; +} diff --git a/challenge-227/laurent-rosenfeld/raku/ch-1.raku b/challenge-227/laurent-rosenfeld/raku/ch-1.raku new file mode 100644 index 0000000000..f04367a9a3 --- /dev/null +++ b/challenge-227/laurent-rosenfeld/raku/ch-1.raku @@ -0,0 +1,12 @@ +sub friday_13 ($y) { + my $count = 0; + for 1..12 -> $m { + # For the Raku Date class, Friday is the + # 5th day of the week + $count++ if Date.new($y, $m, 13).day-of-week == 5; + } + return $count; +} +for 1753, |(2023..2030), 9998 -> $year { + say $year, " => ", friday_13 $year; +} diff --git a/challenge-227/robert-dicicco/python/ch-2.py b/challenge-227/robert-dicicco/python/ch-2.py new file mode 100644 index 0000000000..e089dcad97 --- /dev/null +++ b/challenge-227/robert-dicicco/python/ch-2.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +''' +I got these Roman-Int, Int-Roman routines from O'Reilly +Module: Roman Numerals +Credit: Paul M. Winkler + +AUTHOR: Robert DiCicco +DATE : 2023-07-26 +Challenge 227 Task 2 Roman Maths ( Python ) +''' +import sys + +class py_solution: + def int_to_Roman(self, num): + val = [ + 1000, 900, 500, 400, + 100, 90, 50, 40, + 10, 9, 5, 4, + 1 + ] + syb = [ + "M", "CM", "D", "CD", + "C", "XC", "L", "XL", + "X", "IX", "V", "IV", + "I" + ] + roman_num = '' + i = 0 + while num > 0: + for _ in range(num // val[i]): + roman_num += syb[i] + num -= val[i] + i += 1 + return roman_num + + + def roman_to_int(self, input): + input = input.upper() + roman_numeral_map = (('M', 1000, 3), ('CM', 900, 1), + ('D', 500, 1), ('CD', 400, 1), + ('C', 100, 3), ('XC', 90, 1), + ('L', 50, 1), ('XL', 40, 1), + ('X', 10, 3), ('IX', 9, 1), + ('V', 5, 1), ('IV', 4, 1), ('I', 1, 3)) + result, index = 0, 0 + for numeral, value, maxcount in roman_numeral_map: + count = 0 + while input[index: index+len(numeral)] == numeral: + count += 1 # how many of this numeral we have + result += value + index += len(numeral) + return result + +def main(): + n = len(sys.argv) + if n != 2: + print("Please enter a math problem using Roman numerals") + sys.exit(1) + + problem = sys.argv[1] + parts = problem.split() + left = parts[0] + op = parts[1] + right = parts[2] + lft = py_solution().roman_to_int(left) + rt = py_solution().roman_to_int(right) + + if ( op == '-' and lft - rt == 0): + print(f"{problem} est nulla") + sys.exit(1) + elif (op == '/' and (lft % rt) > 0 ): + print(f"{problem} non potest") + sys.exit(1) + elif (op == '+' and lft + rt > 3999): + print(f"{problem} non potest"); + sys.exit(1) + elif (op == '-' and (lft - rt < 0)): + print(f"{problem} non potest") + sys.exit(1) + elif (op == '/' and (lft % rt != 0)): + print(f"{problem} non potest") + sys.exit(1) + + if ( op == '+'): + val = py_solution().int_to_Roman(lft + rt) + elif ( op == '-'): + val = py_solution().int_to_Roman(lft - rt) + elif ( op == '/'): + val = py_solution().int_to_Roman(int(lft / rt)) + elif ( op == '*'): + val = py_solution().int_to_Roman(int(lft * rt)) + elif ( op == '**'): + val = py_solution().int_to_Roman(int(lft ** rt)) + + print(f"{problem} => {val}") + +if __name__ == "__main__": + main() + +''' +----------------------------------------------------------------- +SAMPLE OUTPUT +python .\RomanMath.py "IV + V" +IV + V => IX + +python .\RomanMath.py "M - I" +M - I => CMXCIX + +python .\RomanMath.py "X / II" +X / II => V + +python .\RomanMath.py "XI * VI" +XI * VI => LXVI + +python .\RomanMath.py "VII ** III" +VII ** III => CCCXLIII + +python .\RomanMath.py "V - V" +V - V est nulla + +python .\RomanMath.py "V / II" +V / II non potest + +python .\RomanMath.py "MMM + M" +MMM + M non potest + +python .\RomanMath.py "V - X" +V - X non potest +''' + + diff --git a/challenge-227/steven-wilson/perl/ch-01.pl b/challenge-227/steven-wilson/perl/ch-1.pl index dd74320843..dd74320843 100644 --- a/challenge-227/steven-wilson/perl/ch-01.pl +++ b/challenge-227/steven-wilson/perl/ch-1.pl diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 07d787370f..8321e97aba 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,32 +1,18 @@ { - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "xAxis" : { - "type" : "category" - }, - "subtitle" : { - "text" : "[Champions: 13] Last updated at 2023-07-25 23:38:36 GMT" - }, - "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/>" - }, "series" : [ { + "colorByPoint" : 1, + "name" : "The Weekly Challenge - 227", "data" : [ { "name" : "Ali Moradi", - "y" : 3, - "drilldown" : "Ali Moradi" + "drilldown" : "Ali Moradi", + "y" : 3 }, { + "drilldown" : "Andrew Shitov", "name" : "Andrew Shitov", - "y" : 4, - "drilldown" : "Andrew Shitov" + "y" : 4 }, { "drilldown" : "David Ferrone", @@ -35,8 +21,13 @@ }, { "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" + "name" : "E. Choroba", + "y" : 2 + }, + { + "name" : "Laurent Rosenfeld", + "drilldown" : "Laurent Rosenfeld", + "y" : 3 }, { "y" : 8, @@ -44,34 +35,44 @@ "drilldown" : "Luca Ferrari" }, { - "drilldown" : "Mark Anderson", "y" : 2, + "drilldown" : "Mark Anderson", "name" : "Mark Anderson" }, { "name" : "Peter Campbell Smith", - "y" : 3, - "drilldown" : "Peter Campbell Smith" + "drilldown" : "Peter Campbell Smith", + "y" : 3 + }, + { + "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", + "y" : 2 }, { - "drilldown" : "Robbie Hatley", "y" : 3, - "name" : "Robbie Hatley" + "name" : "Robbie Hatley", + "drilldown" : "Robbie Hatley" }, { - "drilldown" : "Robert DiCicco", "y" : 4, - "name" : "Robert DiCicco" + "name" : "Robert DiCicco", + "drilldown" : "Robert DiCicco" }, { + "y" : 4, "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West", - "y" : 4 + "name" : "Roger Bell_West" }, { - "y" : 1, + "drilldown" : "Simon Proctor", "name" : "Simon Proctor", - "drilldown" : "Simon Proctor" + "y" : 1 + }, + { + "y" : 1, + "drilldown" : "Steven Wilson", + "name" : "Steven Wilson" }, { "y" : 4, @@ -80,28 +81,48 @@ }, { "name" : "W. Luis Mochan", - "y" : 3, - "drilldown" : "W. Luis Mochan" + "drilldown" : "W. Luis Mochan", + "y" : 3 } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 227" + ] } ], + "legend" : { + "enabled" : 0 + }, + "subtitle" : { + "text" : "[Champions: 16] Last updated at 2023-07-26 18:01:07 GMT" + }, "plotOptions" : { "series" : { - "borderWidth" : 0, "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, + "title" : { + "text" : "The Weekly Challenge - 227" + }, + "chart" : { + "type" : "column" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" } }, + "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/>" + }, "drilldown" : { "series" : [ { - "name" : "Ali Moradi", "id" : "Ali Moradi", + "name" : "Ali Moradi", "data" : [ [ "Perl", @@ -114,38 +135,56 @@ ] }, { - "id" : "Andrew Shitov", - "name" : "Andrew Shitov", "data" : [ [ "Raku", 4 ] - ] + ], + "name" : "Andrew Shitov", + "id" : "Andrew Shitov" }, { "name" : "David Ferrone", - "id" : "David Ferrone", "data" : [ [ "Perl", 1 ] - ] + ], + "id" : "David Ferrone" }, { + "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], - "id" : "E. Choroba", "name" : "E. Choroba" }, { - "name" : "Luca Ferrari", + "name" : "Laurent Rosenfeld", + "data" : [ + [ + "Perl", + 1 + ], + [ + "Raku", + 1 + ], + [ + "Blog", + 1 + ] + ], + "id" : "Laurent Rosenfeld" + }, + { "id" : "Luca Ferrari", + "name" : "Luca Ferrari", "data" : [ [ "Raku", @@ -158,16 +197,18 @@ ] }, { - "name" : "Mark Anderson", "id" : "Mark Anderson", "data" : [ [ "Raku", 2 ] - ] + ], + "name" : "Mark Anderson" }, { + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", "data" : [ [ "Perl", @@ -177,13 +218,20 @@ "Blog", 1 ] - ], - "name" : "Peter Campbell Smith", - "id" : "Peter Campbell Smith" + ] + }, + { + "id" : "Peter Meszaros", + "name" : "Peter Meszaros", + "data" : [ + [ + "Perl", + 2 + ] + ] }, { "name" : "Robbie Hatley", - "id" : "Robbie Hatley", "data" : [ [ "Perl", @@ -193,10 +241,10 @@ "Blog", 1 ] - ] + ], + "id" : "Robbie Hatley" }, { - "name" : "Robert DiCicco", "id" : "Robert DiCicco", "data" : [ [ @@ -207,11 +255,11 @@ "Raku", 2 ] - ] + ], + "name" : "Robert DiCicco" }, { "id" : "Roger Bell_West", - "name" : "Roger Bell_West", "data" : [ [ "Perl", @@ -221,7 +269,8 @@ "Raku", 2 ] - ] + ], + "name" : "Roger Bell_West" }, { "id" : "Simon Proctor", @@ -234,6 +283,17 @@ ] }, { + "id" : "Steven Wilson", + "name" : "Steven Wilson", + "data" : [ + [ + "Perl", + 1 + ] + ] + }, + { + "name" : "Thomas Kohler", "data" : [ [ "Perl", @@ -244,7 +304,6 @@ 2 ] ], - "name" : "Thomas Kohler", "id" : "Thomas Kohler" }, { @@ -263,13 +322,7 @@ } ] }, - "legend" : { - "enabled" : 0 - }, - "chart" : { - "type" : "column" - }, - "title" : { - "text" : "The Weekly Challenge - 227" + "xAxis" : { + "type" : "category" } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 22bebe2049..4728be6ae6 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "subtitle" : { - "text" : "Last updated at 2023-07-25 23:38:36 GMT" - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, "series" : [ { - "dataLabels" : { - "y" : 10, - "format" : "{point.y:.0f}", - "rotation" : -90, - "align" : "right", - "enabled" : "true", - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - }, - "color" : "#FFFFFF" - }, "data" : [ [ "Blog", - 3775 + 3776 ], [ "Perl", - 11598 + 11602 ], [ "Raku", - 6675 + 6676 ] ], - "name" : "Contributions" + "name" : "Contributions", + "dataLabels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "enabled" : "true", + "y" : 10, + "format" : "{point.y:.0f}", + "align" : "right", + "rotation" : -90, + "color" : "#FFFFFF" + } } ], "legend" : { "enabled" : "false" }, - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "Last updated at 2023-07-26 18:01:07 GMT" }, "title" : { "text" : "The Weekly Challenge Contributions [2019 - 2023]" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "chart" : { + "type" : "column" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "xAxis" : { + "type" : "category", + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + } } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 9d83a771af..5b4233d22d 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,17 +1,1173 @@ { + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2023-07-26 18:01:07 GMT" + }, "plotOptions" : { "series" : { "borderWidth" : 0, "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 + "enabled" : 1, + "format" : "{point.y}" } } }, + "series" : [ + { + "name" : "The Weekly Challenge Languages", + "data" : [ + { + "drilldown" : "001", + "name" : "#001", + "y" : 163 + }, + { + "drilldown" : "002", + "name" : "#002", + "y" : 129 + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 87 + }, + { + "y" : 103, + "name" : "#004", + "drilldown" : "004" + }, + { + "y" : 80, + "drilldown" : "005", + "name" : "#005" + }, + { + "drilldown" : "006", + "name" : "#006", + "y" : 61 + }, + { + "y" : 69, + "drilldown" : "007", + "name" : "#007" + }, + { + "drilldown" : "008", + "name" : "#008", + "y" : 82 + }, + { + "y" : 80, + "name" : "#009", + "drilldown" : "009" + }, + { + "drilldown" : "010", + "name" : "#010", + "y" : 69 + }, + { + "y" : 89, + "name" : "#011", + "drilldown" : "011" + }, + { + "y" : 92, + "drilldown" : "012", + "name" : "#012" + }, + { + "y" : 87, + "name" : "#013", + "drilldown" : "013" + }, + { + "drilldown" : "014", + "name" : "#014", + "y" : 102 + }, + { + "y" : 101, + "name" : "#015", + "drilldown" : "015" + }, + { + "drilldown" : "016", + "name" : "#016", + "y" : 75 + }, + { + "y" : 86, + "name" : "#017", + "drilldown" : "017" + }, + { + "name" : "#018", + "drilldown" : "018", + "y" : 83 + }, + { + "y" : 105, + "drilldown" : "019", + "name" : "#019" + }, + { + "y" : 103, + "drilldown" : "020", + "name" : "#020" + }, + { + "y" : 74, + "name" : "#021", + "drilldown" : "021" + }, + { + "drilldown" : "022", + "name" : "#022", + "y" : 72 + }, + { + "drilldown" : "023", + "name" : "#023", + "y" : 101 + }, + { + "name" : "#024", + "drilldown" : "024", + "y" : 77 + }, + { + "y" : 62, + "name" : "#025", + "drilldown" : "025" + }, + { + "name" : "#026", + "drilldown" : "026", + "y" : 76 + }, + { + "y" : 64, + "name" : "#027", + "drilldown" : "027" + }, + { + "y" : 82, + "drilldown" : "028", + "name" : "#028" + }, + { + "drilldown" : "029", + "name" : "#029", + "y" : 83 + }, + { + "drilldown" : "030", + "name" : "#030", + "y" : 121 + }, + { + "drilldown" : "031", + "name" : "#031", + "y" : 93 + }, + { + "y" : 98, + "name" : "#032", + "drilldown" : "032" + }, + { + "drilldown" : "033", + "name" : "#033", + "y" : 114 + }, + { + "y" : 70, + "name" : "#034", + "drilldown" : "034" + }, + { + "y" : 68, + "name" : "#035", + "drilldown" : "035" + }, + { + "drilldown" : "036", + "name" : "#036", + "y" : 70 + }, + { + "name" : "#037", + "drilldown" : "037", + "y" : 70 + }, + { + "y" : 74, + "drilldown" : "038", + "name" : "#038" + }, + { + "y" : 68, + "name" : "#039", + "drilldown" : "039" + }, + { + "y" : 77, + "name" : "#040", + "drilldown" : "040" + }, + { + "y" : 80, + "drilldown" : "041", + "name" : "#041" + }, + { + "name" : "#042", + "drilldown" : "042", + "y" : 98 + }, + { + "y" : 72, + "name" : "#043", + "drilldown" : "043" + }, + { + "y" : 90, + "drilldown" : "044", + "name" : "#044" + }, + { + "y" : 102, + "name" : "#045", + "drilldown" : "045" + }, + { + "name" : "#046", + "drilldown" : "046", + "y" : 93 + }, + { + "drilldown" : "047", + "name" : "#047", + "y" : 88 + }, + { + "y" : 112, + "name" : "#048", + "drilldown" : "048" + }, + { + "drilldown" : "049", + "name" : "#049", + "y" : 93 + }, + { + "y" : 104, + "name" : "#050", + "drilldown" : "050" + }, + { + "drilldown" : "051", + "name" : "#051", + "y" : 95 + }, + { + "name" : "#052", + "drilldown" : "052", + "y" : 93 + }, + { + "name" : "#053", + "drilldown" : "053", + "y" : 105 + }, + { + "name" : "#054", + "drilldown" : "054", + "y" : 107 + }, + { + "drilldown" : "055", + "name" : "#055", + "y" : 92 + }, + { + "y" : 104, + "name" : "#056", + "drilldown" : "056" + }, + { + "drilldown" : "057", + "name" : "#057", + "y" : 86 + }, + { + "y" : 71, + "name" : "#058", + "drilldown" : "058" + }, + { + "y" : 93, + "drilldown" : "059", + "name" : "#059" + }, + { + "drilldown" : "060", + "name" : "#060", + "y" : 89 + }, + { + "y" : 85, + "name" : "#061", + "drilldown" : "061" + }, + { + "y" : 62, + "drilldown" : "062", + "name" : "#062" + }, + { + "name" : "#063", + "drilldown" : "063", + "y" : 93 + }, + { + "y" : 84, + "name" : "#064", + "drilldown" : "064" + }, + { + "drilldown" : "065", + "name" : "#065", + "y" : 77 + }, + { + "name" : "#066", + "drilldown" : "066", + "y" : 88 + }, + { + "drilldown" : "067", + "name" : "#067",< |
