diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-06-14 09:24:11 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-06-14 09:24:11 +0100 |
| commit | f38f02987804feb1a1803099f8c832ec75dfd79a (patch) | |
| tree | 7cda58a295590f3f9c22df1c5effe6d2d9fccc56 | |
| parent | 39373826e39baabba2c424b0aeb5f1e5a293ccca (diff) | |
| download | perlweeklychallenge-club-f38f02987804feb1a1803099f8c832ec75dfd79a.tar.gz perlweeklychallenge-club-f38f02987804feb1a1803099f8c832ec75dfd79a.tar.bz2 perlweeklychallenge-club-f38f02987804feb1a1803099f8c832ec75dfd79a.zip | |
- Added solutions by Mariano Spadaccini.
- Added solutions by Reinier Maliepaard.
- Added solutions by Ali Moradi.
| -rw-r--r-- | challenge-273/reinier-maliepaard/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-273/reinier-maliepaard/perl/ch-1.pl | 47 | ||||
| -rw-r--r-- | challenge-273/reinier-maliepaard/perl/ch-2.pl | 88 | ||||
| -rw-r--r-- | stats/pwc-current.json | 318 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 70 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 3644 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 750 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 48 | ||||
| -rw-r--r-- | stats/pwc-summary-121-150.json | 104 | ||||
| -rw-r--r-- | stats/pwc-summary-151-180.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-181-210.json | 40 | ||||
| -rw-r--r-- | stats/pwc-summary-211-240.json | 126 | ||||
| -rw-r--r-- | stats/pwc-summary-241-270.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-271-300.json | 110 | ||||
| -rw-r--r-- | stats/pwc-summary-301-330.json | 38 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 98 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 130 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 52 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 672 |
19 files changed, 3337 insertions, 3163 deletions
diff --git a/challenge-273/reinier-maliepaard/blog.txt b/challenge-273/reinier-maliepaard/blog.txt new file mode 100644 index 0000000000..7b99b8f2e0 --- /dev/null +++ b/challenge-273/reinier-maliepaard/blog.txt @@ -0,0 +1 @@ +https://reiniermaliepaard.nl/perl/pwc/index.php?id=pwc273 diff --git a/challenge-273/reinier-maliepaard/perl/ch-1.pl b/challenge-273/reinier-maliepaard/perl/ch-1.pl new file mode 100644 index 0000000000..31ce4bff5b --- /dev/null +++ b/challenge-273/reinier-maliepaard/perl/ch-1.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl +use strict; +use warnings; + +sub percentage_of_character { + + my ($str, $char) = (@_); + + # create a new Statistics::Frequency object. + my $f = Statistics::Frequency->new( split(//, $str) ); + return( int( ($f->proportional_frequency($char) * 100) + 0.5) ); + +} + +#TESTS + +my ($str, $char); + +# Example 1 +$str = "perl"; +$char = "e"; +print(percentage_of_character($str, $char), "\n"); # Output: 25 + +# Example 2 +$str = "java"; +$char = "a"; +print(percentage_of_character($str, $char), "\n"); # Output: 50 + +# Example 3 +$str = "python"; +$char = "m"; +print(percentage_of_character($str, $char), "\n"); # Output: 0 + +# Example 4 +$str = "ada"; +$char = "a"; +print(percentage_of_character($str, $char), "\n"); # Output: 67 + +# Example 5 +$str = "ballerina"; +$char = "l"; +print(percentage_of_character($str, $char), "\n"); # Output: 22 + +# Example 6 +$str = "analitik"; +$char = "k"; +print(percentage_of_character($str, $char), "\n"); # Output: 13 diff --git a/challenge-273/reinier-maliepaard/perl/ch-2.pl b/challenge-273/reinier-maliepaard/perl/ch-2.pl new file mode 100644 index 0000000000..d8c125399c --- /dev/null +++ b/challenge-273/reinier-maliepaard/perl/ch-2.pl @@ -0,0 +1,88 @@ +#!/usr/bin/perl +use strict; +use warnings; + +=begin + I prefer not to replicate the interesting regex solutions of others. + Therefore, I chose a different approach using the 'index' method. + + Postulate 1: The string must contain at least one 'b'. Strings like + 'b', 'bb', 'bbb', etc., are also valid. + Postulate 2: If a string contains the characters 'a' and 'b', then + 'a' is not allowed to follow the first 'b'. There are + two cases to consider: + 1. If 'ba' appears at the beginning of a string, it + should be evaluated as 'false'. + 2. If 'ba' appears elsewhere in the string, it must be + preceded by another 'b' to be evaluated as 'true'. + For instance, 'aaba' is 'false' but 'aabba' is 'true'. + + Performance: benchmarking my solution against several regex solutions I + found on GitHub showed that it performs adequately. It is neither the + fastest nor the slowest. +=cut + +sub BafterA { + + # 'b' in $_[0]? + return(0) if(index($_[0], "b") == -1); + # 'ba' at the beginning of $_[0] + return(0) if(index($_[0], "ba") == 0); + # 'bba'? 'aba' not allowed + return(0) if ((index($_[0], "ba") > 0) && (substr($_[0], (index($_[0], "ba")-1), 1) ne "b")); + 1; +} + +# TESTS + +my $str; + +# Example 1 +$str = "aabb"; +print(BafterA($str), "\n"); # Output: 1 + +# Example 2 +$str = "abab"; +print(BafterA($str), "\n"); # Output: 0 + +# Example 3 +$str = "aaa"; +print(BafterA($str), "\n"); # Output: 0 + +# Example 4 +$str = "bbb"; +print(BafterA($str), "\n"); # Output: 1 + +# Own tests + +# Example 5 +$str = "b"; +print(BafterA($str), "\n"); # Output: 1 + +# Example 6 +$str = "a"; +print(BafterA($str), "\n"); # Output: 0 + +# Example 7 +$str = "ba"; +print(BafterA($str), "\n"); # Output: 0 + +# Example 8 +$str = "ab"; +print(BafterA($str), "\n"); # Output: 1 + +# Example 9 +$str = "bba"; +print(BafterA($str), "\n"); # Output: 1 + +# Example 10 +$str = "aba"; +print(BafterA($str), "\n"); # Output: 0 + +# Example 11 +$str = "abba"; +print(BafterA($str), "\n"); # Output: 1 + +# Example 12 +$str = "babba"; +print(BafterA($str), "\n"); # Output: 0 diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 88d16fce3c..1896ab74b5 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,105 +1,4 @@ { - "series" : [ - { - "data" : [ - { - "y" : 2, - "name" : "Andrew Shitov", - "drilldown" : "Andrew Shitov" - }, - { - "y" : 3, - "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby" - }, - { - "name" : "David Ferrone", - "y" : 2, - "drilldown" : "David Ferrone" - }, - { - "drilldown" : "E. Choroba", - "name" : "E. Choroba", - "y" : 2 - }, - { - "drilldown" : "Laurent Rosenfeld", - "y" : 6, - "name" : "Laurent Rosenfeld" - }, - { - "drilldown" : "Luca Ferrari", - "name" : "Luca Ferrari", - "y" : 11 - }, - { - "drilldown" : "Mariano Spadaccini", - "name" : "Mariano Spadaccini", - "y" : 2 - }, - { - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson", - "y" : 2 - }, - { - "drilldown" : "Matthew Neleigh", - "name" : "Matthew Neleigh", - "y" : 2 - }, - { - "name" : "Niels van Dijke", - "y" : 2, - "drilldown" : "Niels van Dijke" - }, - { - "y" : 5, - "name" : "Packy Anderson", - "drilldown" : "Packy Anderson" - }, - { - "name" : "Peter Campbell Smith", - "y" : 3, - "drilldown" : "Peter Campbell Smith" - }, - { - "name" : "Peter Meszaros", - "y" : 2, - "drilldown" : "Peter Meszaros" - }, - { - "name" : "Robbie Hatley", - "y" : 3, - "drilldown" : "Robbie Hatley" - }, - { - "y" : 4, - "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West" - }, - { - "drilldown" : "Thomas Kohler", - "name" : "Thomas Kohler", - "y" : 4 - }, - { - "y" : 4, - "name" : "Ulrich Rieke", - "drilldown" : "Ulrich Rieke" - }, - { - "drilldown" : "Wanderdoc", - "y" : 2, - "name" : "Wanderdoc" - } - ], - "name" : "The Weekly Challenge - 273", - "colorByPoint" : 1 - } - ], - "subtitle" : { - "text" : "[Champions: 18] Last updated at 2024-06-13 12:09:17 GMT" - }, "xAxis" : { "type" : "category" }, @@ -108,23 +7,48 @@ "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/>" + }, "title" : { "text" : "The Weekly Challenge - 273" }, + "chart" : { + "type" : "column" + }, + "legend" : { + "enabled" : 0 + }, "drilldown" : { "series" : [ { - "id" : "Andrew Shitov", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ], + "id" : "Ali Moradi", + "name" : "Ali Moradi" + }, + { + "name" : "Andrew Shitov", "data" : [ [ "Raku", 2 ] ], - "name" : "Andrew Shitov" + "id" : "Andrew Shitov" }, { - "id" : "Dave Jacoby", + "name" : "Dave Jacoby", "data" : [ [ "Perl", @@ -135,7 +59,7 @@ 1 ] ], - "name" : "Dave Jacoby" + "id" : "Dave Jacoby" }, { "id" : "David Ferrone", @@ -148,18 +72,18 @@ "name" : "David Ferrone" }, { - "id" : "E. Choroba", "data" : [ [ "Perl", 2 ] ], + "id" : "E. Choroba", "name" : "E. Choroba" }, { - "id" : "Laurent Rosenfeld", "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -176,7 +100,6 @@ ] }, { - "id" : "Luca Ferrari", "name" : "Luca Ferrari", "data" : [ [ @@ -187,47 +110,48 @@ "Blog", 9 ] - ] + ], + "id" : "Luca Ferrari" }, { + "name" : "Mariano Spadaccini", "data" : [ [ "Perl", 2 ] ], - "name" : "Mariano Spadaccini", "id" : "Mariano Spadaccini" }, { - "id" : "Mark Anderson", + "name" : "Mark Anderson", "data" : [ [ "Raku", 2 ] ], - "name" : "Mark Anderson" + "id" : "Mark Anderson" }, { + "name" : "Matthew Neleigh", "id" : "Matthew Neleigh", "data" : [ [ "Perl", 2 ] - ], - "name" : "Matthew Neleigh" + ] }, { "id" : "Niels van Dijke", - "name" : "Niels van Dijke", "data" : [ [ "Perl", 2 ] - ] + ], + "name" : "Niels van Dijke" }, { "id" : "Packy Anderson", @@ -258,8 +182,8 @@ 1 ] ], - "name" : "Peter Campbell Smith", - "id" : "Peter Campbell Smith" + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" }, { "name" : "Peter Meszaros", @@ -272,7 +196,7 @@ "id" : "Peter Meszaros" }, { - "name" : "Robbie Hatley", + "name" : "Reinier Maliepaard", "data" : [ [ "Perl", @@ -283,23 +207,38 @@ 1 ] ], - "id" : "Robbie Hatley" + "id" : "Reinier Maliepaard" }, { + "id" : "Robbie Hatley", "data" : [ [ "Perl", 2 ], [ - "Raku", - 2 + "Blog", + 1 ] ], + "name" : "Robbie Hatley" + }, + { "name" : "Roger Bell_West", - "id" : "Roger Bell_West" + "id" : "Roger Bell_West", + "data" : [ + [ + "Perl", + 2 + ], + [ + "Raku", + 2 + ] + ] }, { + "name" : "Thomas Kohler", "id" : "Thomas Kohler", "data" : [ [ @@ -310,8 +249,7 @@ "Blog", 2 ] - ], - "name" : "Thomas Kohler" + ] }, { "id" : "Ulrich Rieke", @@ -328,35 +266,135 @@ "name" : "Ulrich Rieke" }, { + "name" : "Wanderdoc", + "id" : "Wanderdoc", "data" : [ [ "Perl", 2 ] - ], - "name" : "Wanderdoc", - "id" : "Wanderdoc" + ] } ] }, "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { "format" : "{point.y}", "enabled" : 1 - }, - "borderWidth" : 0 + } } }, - "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/>" - }, - "legend" : { - "enabled" : 0 + "subtitle" : { + "text" : "[Champions: 20] Last updated at 2024-06-14 08:18:44 GMT" }, - "chart" : { - "type" : "column" - } + "series" : [ + { + "name" : "The Weekly Challenge - 273", + "data" : [ + { + "drilldown" : "Ali Moradi", + "name" : "Ali Moradi", + "y" : 4 + }, + { + "y" : 2, + "name" : "Andrew Shitov", + "drilldown" : "Andrew Shitov" + }, + { + "drilldown" : "Dave Jacoby", + "y" : 3, + "name" : "Dave Jacoby" + }, + { + "drilldown" : "David Ferrone", + "y" : 2, + "name" : "David Ferrone" + }, + { + "name" : "E. Choroba", + "y" : 2, + "drilldown" : "E. Choroba" + }, + { + "drilldown" : "Laurent Rosenfeld", + "name" : "Laurent Rosenfeld", + "y" : 6 + }, + { + "y" : 11, + "name" : "Luca Ferrari", + "drilldown" : "Luca Ferrari" + }, + { + "drilldown" : "Mariano Spadaccini", + "y" : 2, + "name" : "Mariano Spadaccini" + }, + { + "name" : "Mark Anderson", + "y" : 2, + "drilldown" : "Mark Anderson" + }, + { + "y" : 2, + "name" : "Matthew Neleigh", + "drilldown" : "Matthew Neleigh" + }, + { + "drilldown" : "Niels van Dijke", + "name" : "Niels van Dijke", + "y" : 2 + }, + { + "y" : 5, + "name" : "Packy Anderson", + "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" : 3, + "drilldown" : "Reinier Maliepaard" + }, + { + "name" : "Robbie Hatley", + "y" : 3, + "drilldown" : "Robbie Hatley" + }, + { + "drilldown" : "Roger Bell_West", + "name" : "Roger Bell_West", + "y" : 4 + }, + { + "y" : 4, + "name" : "Thomas Kohler", + "drilldown" : "Thomas Kohler" + }, + { + "drilldown" : "Ulrich Rieke", + "y" : 4, + "name" : "Ulrich Rieke" + }, + { + "drilldown" : "Wanderdoc", + "name" : "Wanderdoc", + "y" : 2 + } + ], + "colorByPoint" : 1 + } + ] } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 40f7c0c561..2dd33a30a8 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,63 +1,63 @@ { - "title" : { - "text" : "The Weekly Challenge Contributions [2019 - 2024]" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "subtitle" : { - "text" : "Last updated at 2024-06-13 12:09:17 GMT" - }, "series" : [ { + "name" : "Contributions", "data" : [ [ "Blog", - 4961 + 4962 ], [ "Perl", - 14132 + 14136 ], [ "Raku", - 8194 + 8196 ] ], "dataLabels" : { - "y" : 10, - "enabled" : "true", + "color" : "#FFFFFF", "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" }, - "align" : "right", - "rotation" : -90, "format" : "{point.y:.0f}", - "color" : "#FFFFFF" - }, - "name" : "Contributions" + "y" : 10, + "align" : "right", + "enabled" : "true", + "rotation" : -90 + } } ], - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "legend" : { - "enabled" : "false" + "title" : { + "text" : "The Weekly Challenge Contributions [2019 - 2024]" }, "chart" : { "type" : "column" }, + "legend" : { + "enabled" : "false" + }, "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2024-06-14 08:18:44 GMT" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, + "xAxis" : { + "labels" : { + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + } + }, + "type" : "category" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 6de86fc657..b899ecbd0b 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,13 +1,1389 @@ { - "chart" : { - "type" : "column" + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2024-06-14 08:18:44 GMT" }, - "legend" : { - "enabled" : "false" + "series" : [ + { + "name" : "The Weekly Challenge Languages", + "colorByPoint" : "true", + "data" : [ + { + "name" : "#001", + "y" : 168, + "drilldown" : "001" + }, + { + "drilldown" : "002", + "name" : "#002", + "y" : 133 + }, + { + "drilldown" : "003", + "name" : "#003", + "y" : 91 + }, + { + "y" : 106, + "name" : "#004", + "drilldown" : "004" + }, + { + "drilldown" : "005", + "name" : "#005", + "y" : 82 + }, + { + "name" : "#006", + "y" : 63, + "drilldown" : "006" + }, + { + "name" : "#007", + "y" : 71, + "drilldown" : "007" + }, + { + "drilldown" : "008", + "y" : 84, + "name" : "#008" + }, + { + "drilldown" : "009", + "y" : 82, + "name" : "#009" + }, + { + "drilldown" : "010", + "name" : "#010", + "y" : 71 + }, + { + "name" : "#011", + "y" : 91, + "drilldown" : "011" + }, + { + "name" : "#012", + "y" : 96, + "drilldown" : "012" + }, + { + "drilldown" : "013", + "name" : "#013", + "y" : 88 + }, + { + "drilldown" : "014", + "y" : 104, + "name" : "#014" + }, + { + "drilldown" : "015", + "y" : 103, + "name" : "#015" + }, + { + "name" : "#016", + "y" : 75, + "drilldown" : "016" + }, + { + "drilldown" : "017", + "name" : "#017", + "y" : 87 + }, + { + "drilldown" : "018", + "name" : "#018", + "y" : 84 + }, + { + "drilldown" : "019", + "name" : "#019", + "y" : 105 + }, + { + "y" : 103, + "name" : "#020", + "drilldown" : "020" + }, + { + "y" : 74, + "name" : "#021", + "drilldown" : "021" + }, + { + "drilldown" : "022", + "y" : 72, + "name" : "#022" + }, + { + "drilldown" : "023", + "name" : "#023", + "y" : 101 + }, + { + "y" : 77, + "name" : "#024", + "drilldown" : "024" + }, + { + "y" : 62, + "name" : "#025", + "drilldown" : "025" + }, + { + "name" : "#026", + "y" : 76, + "drilldown" : "026" + }, + { + "name" : "#027", + "y" : 64, + "drilldown" : "027" + }, + { + "drilldown" : "028", + "y" : 82, + "name" : "#028" + }, + { + "drilldown" : "029", + "name" : "#029", + "y" : 83 + }, + { + "y" : 121, + "name" : "#030", + "drilldown" : "030" + }, + { + "name" : "#031", + "y" : 93, + "drilldown" : "031" + }, + { + "name" : "#032", + "y" : 98, + "drilldown" : "032" + }, + { + "name" : "#033", + "y" : 114, + "drilldown" : "033" + }, + { + "name" : "#034", + "y" : 70, + "drilldown" : "034" + }, + { + "name" : "#035", + "y" : 68, + "drilldown" : "035" + }, + { + "drilldown" : "036", + "y" : 70, + "name" : "#036" + }, + { + "name" : "#037", + "y" : 70, + "drilldown" : "037" + }, + { + "name" : "#038", + "y" : 74, + "drilldown" : "038" + }, + { + "y" : 68, + "name" : "#039", + "drilldown" : "039" + }, + { + "drilldown" : "040", + "name" : "#040", + "y" : 77 + }, + { + "y" : 80, + "name" : "#041", + "drilldown" : "041" + }, + { + "drilldown" : "042", + "name" : "#042", + "y" : 98 + }, + { + "name" : "#043", + "y" : 72, + "drilldown" : "043" + }, + { + "drilldown" : "044", + "y" : 90, + "name" : "#044" + }, + { + "drilldown" : "045", + "name" : "#045", + "y" : 102 + }, + { + "y" : 93, + "name" : "#046", + "drilldown" : "046" + }, + { + "drilldown" : "047", + "name" : "#047", + "y" : 88 + }, + { + "y" : 112, + "name" : "#048", + "drilldown" : "048" + }, + { + "y" : 93, + "name" : "#049", + "drilldown" : "049" + }, + { + "drilldown" : "050", + "y" : 104, + "name" : "#050" + }, + { + "drilldown" : "051", + "y" : 95, + "name" : "#051" + }, + { + "y" : 93, + "name" : "#052", + "drilldown" : "052" + }, + { + "drilldown" : "053", + "y" : 105, + "name" : "#053" + }, + { + "drilldown" : "054", + "y" : 107, + "name" : "#054" + }, + { + "y" : 92, + "name" : "#055", + "drilldown" : "055" + }, + { + "drilldown" : "056", + "name" : "#056", + "y" : 104 + }, + { + "drilldown" : "057", + "name" : "#057", |
