diff options
31 files changed, 3798 insertions, 3489 deletions
diff --git a/challenge-284/reinier-maliepaard/blog.txt b/challenge-284/reinier-maliepaard/blog.txt new file mode 100644 index 0000000000..7a8778b274 --- /dev/null +++ b/challenge-284/reinier-maliepaard/blog.txt @@ -0,0 +1 @@ +https://reiniermaliepaard.nl/perl/pwc/index.php?id=pwc284 diff --git a/challenge-284/reinier-maliepaard/perl/ch-1.pl b/challenge-284/reinier-maliepaard/perl/ch-1.pl new file mode 100644 index 0000000000..b9da9e2fd6 --- /dev/null +++ b/challenge-284/reinier-maliepaard/perl/ch-1.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Statistics::Frequency; + +=begin +Dive back again into the Statistics::Frequency module - because we clearly can't get enough of it +=cut + +sub lucky_integer { + my @ints = @_; + + # return -1 if the input array is empty + return(-1) unless @ints; + + # create a new Statistics::Frequency object + my $freq = Statistics::Frequency->new(@ints); + + # filter the list to only include elements where the + # frequency equals the element's value + my @list = grep { $_ == $freq->frequency($_) } @ints; + + # sort the filtered list in descending order + @list = sort { $b <=> $a } @list; + + # return the first element (largest) or -1 if the list is empty + return(@list ? $list[0] : -1); +} + +# Tests + +my @ints; + +# Example 1 +@ints = (2, 2, 3, 4); +print(lucky_integer(@ints), "\n"); # Output: 2 + +# Example 2 +@ints = (1, 2, 2, 3, 3, 3); +print(lucky_integer(@ints), "\n"); # Output: 3 + +# Example 3 +@ints = (1, 1, 1, 3); +print(lucky_integer(@ints), "\n"); # Output: -1 diff --git a/challenge-284/reinier-maliepaard/perl/ch-2.pl b/challenge-284/reinier-maliepaard/perl/ch-2.pl new file mode 100644 index 0000000000..864d839dbd --- /dev/null +++ b/challenge-284/reinier-maliepaard/perl/ch-2.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +use strict; +use warnings; + +=begin +Just straightforward coding, easily following the task description. +=cut + +sub relative_sort { + + # retrieve the first list from the reference + my @list1 = @{ shift() }; + # retrieve the second list from the reference + my @list2 = @{ shift() }; + + # create a hash map for the positions of elements in @list2 + my %element_order_list2 = map { $list2[$_] => $_ } 0 .. $#list2; + + # separate @list1 elements into those in @list2 and those not in @list2 + my (@in_list2, @not_in_list2); + foreach ( @list1 ) { + ( exists $element_order_list2{$_} ) ? push(@in_list2, $_) + : push(@not_in_list2, $_); + } + + # sort @in_list2 according to the order in @list2 + @in_list2 = sort { $element_order_list2{$a} <=> $element_order_list2{$b} } @in_list2; + + # sort @not_in_list2 in ascending order + @not_in_list2 = sort { $a <=> $b } @not_in_list2; + + # combine both lists + return(@in_list2, @not_in_list2); +} + +# Tests + +my (@list1, @list2); + +# Example 1 +@list1 = (2, 3, 9, 3, 1, 4, 6, 7, 2, 8, 5); +@list2 = (2, 1, 4, 3, 5, 6); +print("(", join(", ", relative_sort(\@list1, \@list2)), ")\n"); # Output: (2, 2, 1, 4, 3, 3, 5, 6, 7, 8, 9) + +# Example 2 +@list1 = (3, 3, 4, 6, 2, 4, 2, 1, 3); +@list2 = (1, 3, 2); +print("(", join(", ", relative_sort(\@list1, \@list2)), ")\n"); # Output: (1, 3, 3, 3, 2, 2, 4, 4, 6) + +# Example 3 +@list1 = (3, 0, 5, 0, 2, 1, 4, 1, 1); +@list2 = (1, 0, 3, 2); +print("(", join(", ", relative_sort(\@list1, \@list2)), ")\n"); # Output: (1, 1, 1, 0, 0, 3, 2, 4, 5) diff --git a/stats/pwc-challenge-270.json b/stats/pwc-challenge-270.json index 88a1bc6d3b..0286306fee 100644 --- a/stats/pwc-challenge-270.json +++ b/stats/pwc-challenge-270.json @@ -1,33 +1,46 @@ { - "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/>" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "type" : "category" }, "subtitle" : { - "text" : "[Champions: 31] Last updated at 2024-07-29 17:29:09 GMT" + "text" : "[Champions: 32] Last updated at 2024-08-30 19:41:16 GMT" + }, + "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/>" }, "series" : [ { + "name" : "The Weekly Challenge - 270", + "colorByPoint" : 1, "data" : [ { - "drilldown" : "Arne Sommer", "y" : 3, - "name" : "Arne Sommer" + "name" : "Arne Sommer", + "drilldown" : "Arne Sommer" }, { - "drilldown" : "Athanasius", "y" : 4, - "name" : "Athanasius" + "name" : "Athanasius", + "drilldown" : "Athanasius" }, { - "name" : "BarrOff", "drilldown" : "BarrOff", - "y" : 1 + "y" : 1, + "name" : "BarrOff" }, { - "name" : "Bob Lied", "drilldown" : "Bob Lied", + "name" : "Bob Lied", "y" : 2 }, { @@ -37,58 +50,58 @@ }, { "name" : "Dave Jacoby", - "drilldown" : "Dave Jacoby", - "y" : 3 + "y" : 3, + "drilldown" : "Dave Jacoby" }, { - "y" : 1, "drilldown" : "David Ferrone", - "name" : "David Ferrone" + "name" : "David Ferrone", + "y" : 1 }, { - "y" : 3, "drilldown" : "E. Choroba", - "name" : "E. Choroba" + "name" : "E. Choroba", + "y" : 3 }, { + "drilldown" : "Feng Chang", "name" : "Feng Chang", - "y" : 2, - "drilldown" : "Feng Chang" + "y" : 2 }, { "drilldown" : "Jaldhar H. Vyas", - "y" : 5, - "name" : "Jaldhar H. Vyas" + "name" : "Jaldhar H. Vyas", + "y" : 5 }, { "drilldown" : "Jan Krnavek", - "y" : 1, - "name" : "Jan Krnavek" + "name" : "Jan Krnavek", + "y" : 1 }, { - "y" : 4, "drilldown" : "Jorg Sommrey", + "y" : 4, "name" : "Jorg Sommrey" }, { + "name" : "Lance Wicks", "y" : 1, - "drilldown" : "Lance Wicks", - "name" : "Lance Wicks" + "drilldown" : "Lance Wicks" }, { - "y" : 3, "drilldown" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" + "name" : "Laurent Rosenfeld", + "y" : 3 }, { - "drilldown" : "Luca Ferrari", + "name" : "Luca Ferrari", "y" : 12, - "name" : "Luca Ferrari" + "drilldown" : "Luca Ferrari" }, { "y" : 1, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson" }, { "name" : "Matthew Neleigh", @@ -106,44 +119,49 @@ "name" : "Nelo Tovar" }, { - "name" : "Niels van Dijke", + "drilldown" : "Niels van Dijke", "y" : 2, - "drilldown" : "Niels van Dijke" + "name" : "Niels van Dijke" }, { - "y" : 5, "drilldown" : "Packy Anderson", - "name" : "Packy Anderson" + "name" : "Packy Anderson", + "y" : 5 + }, + { + "y" : 2, + "name" : "Paulo Custodio", + "drilldown" : "Paulo Custodio" }, { - "name" : "Peter Campbell Smith", "drilldown" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith", "y" : 3 }, { - "name" : "Peter Meszaros", "drilldown" : "Peter Meszaros", + "name" : "Peter Meszaros", "y" : 2 }, { - "y" : 4, "drilldown" : "Reinier Maliepaard", + "y" : 4, "name" : "Reinier Maliepaard" }, { - "name" : "Robbie Hatley", "drilldown" : "Robbie Hatley", - "y" : 2 + "y" : 2, + "name" : "Robbie Hatley" }, { - "y" : 2, "drilldown" : "Robert Ransbottom", + "y" : 2, "name" : "Robert Ransbottom" }, { "name" : "Roger Bell_West", - "drilldown" : "Roger Bell_West", - "y" : 5 + "y" : 5, + "drilldown" : "Roger Bell_West" }, { "drilldown" : "Simon Green", @@ -151,46 +169,40 @@ "name" : "Simon Green" }, { - "drilldown" : "Thomas Kohler", + "name" : "Thomas Kohler", "y" : 4, - "name" : "Thomas Kohler" + "drilldown" : "Thomas Kohler" }, { - "name" : "Ulrich Rieke", + "drilldown" : "Ulrich Rieke", "y" : 4, - "drilldown" : "Ulrich Rieke" + "name" : "Ulrich Rieke" }, { "drilldown" : "W. Luis Mochan", - "y" : 3, - "name" : "W. Luis Mochan" + "name" : "W. Luis Mochan", + "y" : 3 } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 270" + ] } ], - "chart" : { - "type" : "column" - }, "plotOptions" : { "series" : { + "borderWidth" : 0, "dataLabels" : { "format" : "{point.y}", "enabled" : 1 - }, - "borderWidth" : 0 + } } }, - "xAxis" : { - "type" : "category" - }, - "title" : { - "text" : "The Weekly Challenge - 270" + "legend" : { + "enabled" : 0 }, "drilldown" : { "series" : [ { + "id" : "Arne Sommer", + "name" : "Arne Sommer", "data" : [ [ "Raku", @@ -200,13 +212,9 @@ "Blog", 1 ] - ], - "name" : "Arne Sommer", - "id" : "Arne Sommer" + ] }, { - "id" : "Athanasius", - "name" : "Athanasius", "data" : [ [ "Perl", @@ -216,21 +224,23 @@ "Raku", 2 ] - ] + ], + "name" : "Athanasius", + "id" : "Athanasius" }, { + "name" : "BarrOff", + "id" : "BarrOff", "data" : [ [ "Raku", 1 ] - ], - "id" : "BarrOff", - "name" : "BarrOff" + ] }, { - "id" : "Bob Lied", "name" : "Bob Lied", + "id" : "Bob Lied", "data" : [ [ "Perl", @@ -259,8 +269,8 @@ 1 ] ], - "id" : "Dave Jacoby", - "name" : "Dave Jacoby" + "name" : "Dave Jacoby", + "id" : "Dave Jacoby" }, { "name" : "David Ferrone", @@ -273,8 +283,6 @@ ] }, { - "name" : "E. Choroba", - "id" : "E. Choroba", "data" : [ [ "Perl", @@ -284,21 +292,21 @@ "Blog", 1 ] - ] + ], + "name" : "E. Choroba", + "id" : "E. Choroba" }, { + "name" : "Feng Chang", + "id" : "Feng Chang", "data" : [ [ "Raku", 2 ] - ], - "id" : "Feng Chang", - "name" : "Feng Chang" + ] }, { - "id" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas", "data" : [ [ "Perl", @@ -312,11 +320,13 @@ "Blog", 1 ] - ] + ], + "name" : "Jaldhar H. Vyas", + "id" : "Jaldhar H. Vyas" }, { - "name" : "Jan Krnavek", "id" : "Jan Krnavek", + "name" : "Jan Krnavek", "data" : [ [ "Raku", @@ -325,8 +335,6 @@ ] }, { - "id" : "Jorg Sommrey", - "name" : "Jorg Sommrey", "data" : [ [ "Perl", @@ -336,19 +344,23 @@ "Blog", 2 ] - ] + ], + "id" : "Jorg Sommrey", + "name" : "Jorg Sommrey" }, { + "name" : "Lance Wicks", + "id" : "Lance Wicks", "data" : [ [ "Perl", 1 ] - ], - "id" : "Lance Wicks", - "name" : "Lance Wicks" + ] }, { + "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ "Perl", @@ -362,9 +374,7 @@ "Blog", 1 ] - ], - "id" : "Laurent Rosenfeld", - "name" : "Laurent Rosenfeld" + ] }, { "data" : [ @@ -377,8 +387,8 @@ 10 ] ], - "id" : "Luca Ferrari", - "name" : "Luca Ferrari" + "name" : "Luca Ferrari", + "id" : "Luca Ferrari" }, { "data" : [ @@ -387,22 +397,20 @@ 1 ] ], - "id" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "id" : "Mark Anderson" }, { + "name" : "Matthew Neleigh", + "id" : "Matthew Neleigh", "data" : [ [ "Perl", 1 ] - ], - "id" : "Matthew Neleigh", - "name" : "Matthew Neleigh" + ] }, { - "id" : "Matthias Muth", - "name" : "Matthias Muth", "data" : [ [ "Perl", @@ -412,7 +420,9 @@ "Blog", 1 ] - ] + ], + "name" : "Matthias Muth", + "id" : "Matthias Muth" }, { "data" : [ @@ -421,8 +431,8 @@ 2 ] ], - "id" : "Nelo Tovar", - "name" : "Nelo Tovar" + "name" : "Nelo Tovar", + "id" : "Nelo Tovar" }, { "name" : "Niels van Dijke", @@ -453,8 +463,16 @@ "name" : "Packy Anderson" }, { - "name" : "Peter Campbell Smith", - "id" : "Peter Campbell Smith", + "name" : "Paulo Custodio", + "id" : "Paulo Custodio", + "data" : [ + [ + "Perl", + 2 + ] + ] + }, + { "data" : [ [ "Perl", @@ -464,17 +482,19 @@ "Blog", 1 ] - ] + ], + "id" : "Peter Campbell Smith", + "name" : "Peter Campbell Smith" }, { + "id" : "Peter Meszaros", + "name" : "Peter Meszaros", "data" : [ [ "Perl", 2 ] - ], - "id" : "Peter Meszaros", - "name" : "Peter Meszaros" + ] }, { "name" : "Reinier Maliepaard", @@ -491,8 +511,8 @@ ] }, { - "name" : "Robbie Hatley", "id" : "Robbie Hatley", + "name" : "Robbie Hatley", "data" : [ [ "Perl", @@ -511,8 +531,8 @@ 2 ] ], - "name" : "Robert Ransbottom", - "id" : "Robert Ransbottom" + "id" : "Robert Ransbottom", + "name" : "Robert Ransbottom" }, { "id" : "Roger Bell_West", @@ -533,8 +553,8 @@ ] }, { - "name" : "Simon Green", "id" : "Simon Green", + "name" : "Simon Green", "data" : [ [ "Perl", @@ -575,6 +595,8 @@ "name" : "Ulrich Rieke" }, { + "id" : "W. Luis Mochan", + "name" : "W. Luis Mochan", "data" : [ [ "Perl", @@ -584,18 +606,11 @@ "Blog", 1 ] - ], - "name" : "W. Luis Mochan", - "id" : "W. Luis Mochan" + ] } ] }, - "legend" : { - "enabled" : 0 - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "title" : { + "text" : "The Weekly Challenge - 270" } } diff --git a/stats/pwc-challenge-271.json b/stats/pwc-challenge-271.json index 519d8b69d7..0c9ee8cbaf 100644 --- a/stats/pwc-challenge-271.json +++ b/stats/pwc-challenge-271.json @@ -1,221 +1,7 @@ { - "xAxis" : { - "type" : "category" - }, "title" : { "text" : "The Weekly Challenge - 271" }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "chart" : { - "type" : "column" - }, - "series" : [ - { - "data" : [ - { - "drilldown" : "Ali Moradi", - "y" : 5, - "name" : "Ali Moradi" - }, - { - "name" : "Andrew Schneider", - "drilldown" : "Andrew Schneider", - "y" : 2 - }, - { - "name" : "Arne Sommer", - "y" : 3, - "drilldown" : "Arne Sommer" - }, - { - "name" : "Athanasius", - "drilldown" : "Athanasius", - "y" : 4 - }, - { - "y" : 2, - "drilldown" : "BarrOff", - "name" : "BarrOff" - }, - { - "name" : "Bob Lied", - "drilldown" : "Bob Lied", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "Bruce Gray", - "name" : "Bruce Gray" - }, - { - "name" : "Cheok-Yin Fung", - "drilldown" : "Cheok-Yin Fung", - "y" : 2 - }, - { - "name" : "Dave Jacoby", - "y" : 3, - "drilldown" : "Dave Jacoby" - }, - { - "name" : "David Ferrone", - "drilldown" : "David Ferrone", - "y" : 2 - }, - { - "y" : 2, - "drilldown" : "E. Choroba", - "name" : "E. Choroba" - }, - { - "y" : 2, - "drilldown" : "Feng Chang", - "name" : "Feng Chang" - }, - { - "y" : 5, - "drilldown" : "Jaldhar H. Vyas", - "name" : "Jaldhar H. Vyas" - }, - { - "name" : "Jan Krnavek", - "drilldown" : "Jan Krnavek", - "y" : 2 - }, - { - "drilldown" : "Jorg Sommrey", - "y" : 3, - "name" : "Jorg Sommrey" - }, - { - "drilldown" : "Kjetil Skotheim", - "y" : 2, - "name" : "Kjetil Skotheim" - }, - { - "name" : "Laurent Rosenfeld", - "drilldown" : "Laurent Rosenfeld", - "y" : 6 - }, - { - "name" : "Luca Ferrari", - "y" : 12, - "drilldown" : "Luca Ferrari" - }, - { - "name" : "Mariano Spadaccini", - "y" : 2, - "drilldown" : "Mariano Spadaccini" - }, - { - "y" : 2, - "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" - }, - { - "y" : 2, - "drilldown" : "Matthew Neleigh", - "name" : "Matthew Neleigh" - }, - { - "y" : 3, - "drilldown" : "Matthias Muth", - "name" : "Matthias Muth" - }, - { - "name" : "Nelo Tovar", - "drilldown" : "Nelo Tovar", - "y" : 2 - }, - { - "drilldown" : "Niels van Dijke", - "y" : 2, - "name" : "Niels van Dijke" - }, - { - "drilldown" : "Packy Anderson", - "y" : 5, - "name" : "Packy Anderson" - }, - { - "name" : "Peter Campbell Smith", - "y" : 3, - "drilldown" : "Peter Campbell Smith" - }, - { - "drilldown" : "Peter Meszaros", - "y" : 2, - "name" : "Peter Meszaros" - }, - { - "name" : "Reinier Maliepaard", - "y" : 3, - "drilldown" : "Reinier Maliepaard" - }, - { - "drilldown" : "Robbie Hatley", - "y" : 3, - "name" : "Robbie Hatley" - }, - { - "name" : "Robert Ransbottom", - "y" : 2, - "drilldown" : "Robert Ransbottom" - }, - { - "y" : 5, - "drilldown" : "Roger Bell_West", - "name" : "Roger Bell_West" - }, - { - "drilldown" : "Simon Green", - "y" : 3, - "name" : "Simon Green" - }, - { - "name" : "Thomas Kohler", - "y" : 4, - "drilldown" : "Thomas Kohler" - }, - { - "drilldown" : "W. Luis Mochan", - "y" : 3, - "name" : "W. Luis Mochan" - }, - { - "name" : "Wanderdoc", - "drilldown" : "Wanderdoc", - "y" : 2 - } - ], - "colorByPoint" : 1, - "name" : "The Weekly Challenge - 271" - } - ], - "subtitle" : { - "text" : "[Champions: 35] Last updated at 2024-07-29 17:29:09 GMT" - }, - "tooltip" : { - "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/>", - "followPointer" : 1 - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "legend" : { - "enabled" : 0 - }, "drilldown" : { "series" : [ { @@ -257,8 +43,8 @@ 1 ] ], - "id" : "Arne Sommer", - "name" : "Arne Sommer" + "name" : "Arne Sommer", + "id" : "Arne Sommer" }, { "id" : "Athanasius", @@ -281,18 +67,18 @@ |
