diff options
| -rw-r--r-- | challenge-025/colin-crain/perl5/ch-1.pl | 139 | ||||
| -rw-r--r-- | stats/pwc-current.json | 151 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 70 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 410 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 502 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 104 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 94 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 260 |
10 files changed, 977 insertions, 823 deletions
diff --git a/challenge-025/colin-crain/perl5/ch-1.pl b/challenge-025/colin-crain/perl5/ch-1.pl new file mode 100644 index 0000000000..773c9618d1 --- /dev/null +++ b/challenge-025/colin-crain/perl5/ch-1.pl @@ -0,0 +1,139 @@ +#! /opt/local/bin/perl +# +# pokemon.pl +# +# task: Generate a longest sequence of the following “English Pokemon” names +# where each name starts with the last letter of previous name. +# +# method: there are 70! combinations of the 70 pokemon named, or about +# 1.197857e+100. By noting first and last letters of each name, and +# creating a lookup index of first letters pointing to a list of pokemon +# whose names start with that letter we can reduce the search space. The +# number of valid permutations is then a little over 5,000,000. Using a +# recursive descent down the search tree we examine only these valid linkages, +# keeping a running tally of the longest list found. After determining the +# length of the longest list and the first such occurence at that length, I +# wondered how many such lists of that length existed, so created a global +# "list of lists" and preserved them as they came up. +# +# results: examining the lists of longest possible chains reveals groupings of +# pokemon names that begin and end with the same letters that can be interchanged +# to create new combinations without changing the overall list length. For example: +# seaking, girafarig, gabite, emboar +# can be swapped with the single entity +# simisear +# in any list containing both groupings without changing the list length. +# As such there are 1248 different lists of maximum length 23 pokemon. +# As a further aside I decided to combine these creatures into one monstrous +# mega-monster by concatenating one such list of 23 creatures into one name. +# +# 2019 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + + + +use warnings; +use strict; +use feature ":5.26"; + +## ## ## ## ## CONFIG + +my @pokemon = qw(audino bagon baltoy banette bidoof braviary bronzor carracosta +charmeleon cresselia croagunk darmanitan deino emboar emolga exeggcute gabite +girafarig gulpin haxorus heatmor heatran ivysaur jellicent jumpluff kangaskhan +kricketune landorus ledyba loudred lumineon lunatone machamp magnezone mamoswine +nosepass petilil pidgeotto pikachu pinsir poliwrath poochyena porygon2 porygonz +registeel relicanth remoraid rufflet sableye scolipede scrafty seaking sealeo +silcoon simisear snivy snorlax spoink starly tirtouga trapinch treecko tyrogue +vigoroth vulpix wailord wartortle whismur wingull yamask); + +## ## ## ## ## MAIN + +## create the pokehash data structure +# example: $pokehash->{tyrogue} => { 'first' => 't', +# 'last' => 'e' } +my $pokehash = { map { $_, { "first" => (substr $_, 0, 1), "last" => (substr $_, -1) } } @pokemon }; + +my $index = {}; +for my $monster ( @pokemon ) { + if (exists $index->{ $pokehash->{$monster}->{first} }) { + push $index->{ $pokehash->{$monster}->{first} }->@*, $monster; + } + else { + $index->{ $pokehash->{$monster}->{first} } = [$monster]; + } + } + +my $list = []; +my $longest = []; +my $list_of_longest_lists = []; ## global + +## iterate through the pokemon, doing a depth-first descent of permutations through the graph +## of each pokemon linked to each pokemon whose name starts with the last letter of the previous. +for (@pokemon) { + $list = [$_]; + $longest = get_next_node( $pokehash, $index, $list, $longest); +} + +## report the findings +say "from a group of ", scalar @pokemon, " pokemon:"; +say "longest list length: ", scalar $longest->@*, " pokemon"; +say "first list found at this length: \n", (join ', ', $longest->@*); +say "number of lists at this length: ", scalar $list_of_longest_lists->@*; +my $i; +for my $list ( $list_of_longest_lists->@* ){ + print ++$i, ":\t"; + say (join ', ', $list->@*); +} + +## create a monstrous concatenation of the names of the first list into one long word +my $lastlink = $longest->[-1]; +my $monstrosity; +for my $monster ( $longest->@* ) { + chop $monster; + $monstrosity .= $monster; +} +$monstrosity .= $lastlink; +say "one name for a giant monstrosity of a creature composed of an amagamation of all ", + scalar $longest->@*, " pokemon is: \n", $monstrosity; + + +## ## ## ## ## SUBS + +sub get_next_node { + my ( $pokehash, $index, $list, $longest) = @_; + + ## copy the current list + my @newlist = $list->@*; + + ## if the current list exceeds the length of the longest list, replace it with this one + if (scalar @newlist > scalar $longest->@*) { + $longest = \@newlist; + $list_of_longest_lists = [\@newlist]; ## reset the list of lists for this new length + } + elsif ( scalar @newlist == scalar $longest->@* ) { + push $list_of_longest_lists->@*, \@newlist; + } + + my $current_pokemon = $newlist[-1]; + my $last_letter = $pokehash->{$current_pokemon}->{last}; + + ## if there is no index lookup there are no more possible links so return + return $longest if not exists $index->{$last_letter}; + + ## create a lookup hash for the pokemon that are in the current list + my %inlist = map { $_ => 1 } @newlist; + + ## get each possible following pokemon from the index + for my $pokemon ( $index->{$last_letter}->@* ){ + + ## skip if this pokemon has already been chained + next if exists $inlist{$pokemon}; + + ## extend the chain and recurse + my $nextlist = [@newlist, $pokemon]; + $longest = get_next_node( $pokehash, $index, $nextlist, $longest); + } + + return $longest; +} diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 509f5be389..6551dd9a42 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,9 +1,4 @@ { - "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 - }, "yAxis" : { "title" : { "text" : "Total Solutions" @@ -22,21 +17,22 @@ 2 ] ], - "name" : "Adam Russell", - "id" : "Adam Russell" + "id" : "Adam Russell", + "name" : "Adam Russell" }, { - "id" : "Andrezgz", - "name" : "Andrezgz", "data" : [ [ "Perl 5", 2 ] - ] + ], + "id" : "Andrezgz", + "name" : "Andrezgz" }, { "name" : "Arne Sommer", + "id" : "Arne Sommer", "data" : [ [ "Perl 6", @@ -46,10 +42,10 @@ "Blog", 1 ] - ], - "id" : "Arne Sommer" + ] }, { + "name" : "Athanasius", "id" : "Athanasius", "data" : [ [ @@ -60,21 +56,29 @@ "Perl 6", 1 ] + ] + }, + { + "data" : [ + [ + "Perl 5", + 1 + ] ], - "name" : "Athanasius" + "id" : "Colin Crain", + "name" : "Colin Crain" }, { - "name" : "Duane Powell", "data" : [ [ "Perl 5", 2 ] ], + "name" : "Duane Powell", "id" : "Duane Powell" }, { - "id" : "E. Choroba", "data" : [ [ "Perl 5", @@ -85,19 +89,21 @@ 1 ] ], - "name" : "E. Choroba" + "name" : "E. Choroba", + "id" : "E. Choroba" }, { + "id" : "Guillermo Ramos", "name" : "Guillermo Ramos", "data" : [ [ "Perl 5", 2 ] - ], - "id" : "Guillermo Ramos" + ] }, { + "name" : "Joelle Maslak", "id" : "Joelle Maslak", "data" : [ [ @@ -108,12 +114,11 @@ "Perl 6", 2 ] - ], - "name" : "Joelle Maslak" + ] }, { - "id" : "Kevin Colyer", "name" : "Kevin Colyer", + "id" : "Kevin Colyer", "data" : [ [ "Perl 6", @@ -122,7 +127,6 @@ ] }, { - "id" : "Laurent Rosenfeld", "data" : [ [ "Perl 5", @@ -137,19 +141,22 @@ 1 ] ], + "id" : "Laurent Rosenfeld", "name" : "Laurent Rosenfeld" }, { - "name" : "Ozzy", "data" : [ [ "Perl 6", 1 ] ], - "id" : "Ozzy" + "id" : "Ozzy", + "name" : "Ozzy" }, { + "name" : "Roger Bell West", + "id" : "Roger Bell West", "data" : [ [ "Perl 5", @@ -159,12 +166,11 @@ "Blog", 1 ] - ], - "name" : "Roger Bell West", - "id" : "Roger Bell West" + ] }, { "name" : "Ruben Westerberg", + "id" : "Ruben Westerberg", "data" : [ [ "Perl 5", @@ -174,21 +180,21 @@ "Perl 6", 2 ] - ], - "id" : "Ruben Westerberg" + ] }, { + "name" : "Simon Proctor", + "id" : "Simon Proctor", "data" : [ [ "Perl 6", 1 ] - ], - "name" : "Simon Proctor", - "id" : "Simon Proctor" + ] }, { "name" : "Yet Ebreo", + "id" : "Yet Ebreo", "data" : [ [ "Perl 5", @@ -202,31 +208,21 @@ "Blog", 1 ] - ], - "id" : "Yet Ebreo" + ] } ] }, "xAxis" : { "type" : "category" }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, - "title" : { - "text" : "Perl Weekly Challenge - 025" - }, "legend" : { "enabled" : 0 }, "subtitle" : { - "text" : "[Champions: 15] Last updated at 2019-09-15 22:23:45 GMT" + "text" : "[Champions: 16] Last updated at 2019-09-15 22:52:58 GMT" + }, + "title" : { + "text" : "Perl Weekly Challenge - 025" }, "series" : [ { @@ -234,48 +230,53 @@ "data" : [ { "drilldown" : "Adam Russell", - "y" : 4, - "name" : "Adam Russell" + "name" : "Adam Russell", + "y" : 4 }, { + "y" : 2, "name" : "Andrezgz", - "drilldown" : "Andrezgz", - "y" : 2 + "drilldown" : "Andrezgz" }, { - "y" : 3, "drilldown" : "Arne Sommer", + "y" : 3, "name" : "Arne Sommer" }, { - "name" : "Athanasius", "y" : 2, + "name" : "Athanasius", "drilldown" : "Athanasius" }, { - "name" : "Duane Powell", + "drilldown" : "Colin Crain", + "y" : 1, + "name" : "Colin Crain" + }, + { "drilldown" : "Duane Powell", + "name" : "Duane Powell", "y" : 2 }, { - "drilldown" : "E. Choroba", + "name" : "E. Choroba", "y" : 3, - "name" : "E. Choroba" + "drilldown" : "E. Choroba" }, { - "name" : "Guillermo Ramos", "y" : 2, + "name" : "Guillermo Ramos", "drilldown" : "Guillermo Ramos" }, { + "y" : 4, "name" : "Joelle Maslak", - "drilldown" : "Joelle Maslak", - "y" : 4 + "drilldown" : "Joelle Maslak" }, { - "name" : "Kevin Colyer", + "drilldown" : "Kevin Colyer", "y" : 2, - "drilldown" : "Kevin Colyer" + "name" : "Kevin Colyer" }, { "name" : "Laurent Rosenfeld", @@ -283,29 +284,29 @@ "drilldown" : "Laurent Rosenfeld" }, { - "drilldown" : "Ozzy", "y" : 1, - "name" : "Ozzy" + "name" : "Ozzy", + "drilldown" : "Ozzy" }, { - "name" : "Roger Bell West", "y" : 3, + "name" : "Roger Bell West", "drilldown" : "Roger Bell West" }, { - "y" : 4, "drilldown" : "Ruben Westerberg", + "y" : 4, "name" : "Ruben Westerberg" }, { - "name" : "Simon Proctor", "drilldown" : "Simon Proctor", + "name" : "Simon Proctor", "y" : 1 }, { "drilldown" : "Yet Ebreo", - "y" : 5, - "name" : "Yet Ebreo" + "name" : "Yet Ebreo", + "y" : 5 } ], "colorByPoint" : 1 @@ -313,5 +314,19 @@ ], "chart" : { "type" : "column" + }, + "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 + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index a09923646c..3d6509c1c5 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,29 +2,20 @@ "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" }, - "xAxis" : { - "labels" : { - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - } - }, - "type" : "category" - }, - "subtitle" : { - "text" : "Last updated at 2019-09-15 22:24:04 GMT" - }, - "title" : { - "text" : "Perl Weekly Challenge Contributions - 2019" - }, - "yAxis" : { - "min" : 0, - "title" : { - "text" : null - } - }, "series" : [ { + "dataLabels" : { + "format" : "{point.y:.0f}", + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + }, + "enabled" : "true", + "y" : 10, + "align" : "right", + "rotation" : -90, + "color" : "#FFFFFF" + }, "name" : "Contributions", "data" : [ [ @@ -33,30 +24,39 @@ ], [ "Perl 5", - 1026 + 1027 ], [ "Perl 6", 621 ] - ], - "dataLabels" : { - "rotation" : -90, - "format" : "{point.y:.0f}", - "y" : 10, - "enabled" : "true", - "color" : "#FFFFFF", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "align" : "right" - } + ] } ], "chart" : { "type" : "column" }, + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } + }, + "type" : "category" + }, + "subtitle" : { + "text" : "Last updated at 2019-09-15 22:53:09 GMT" + }, + "title" : { + "text" : "Perl Weekly Challenge Contributions - 2019" + }, + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 + }, "legend" : { "enabled" : "false" } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 7591a90d61..e4ef6e88f5 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -2,20 +2,165 @@ "xAxis" : { "type" : "category" }, - "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" + "chart" : { + "type" : "column" }, - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-15 22:24:04 GMT" + "series" : [ + { + "colorByPoint" : "true", + "name" : "Perl Weekly Challenge Languages", + "data" : [ + { + "y" : 132, + "drilldown" : "001", + "name" : "#001" + }, + { + "drilldown" : "002", + "name" : "#002", + "y" : 104 + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 66 + }, + { + "name" : "#004", + "drilldown" : "004", + "y" : 86 + }, + { + "drilldown" : "005", + "name" : "#005", + "y" : 66 + }, + { + "y" : 47, + "drilldown" : "006", + "name" : "#006" + }, + { + "y" : 55, + "drilldown" : "007", + "name" : "#007" + }, + { + "drilldown" : "008", + "name" : "#008", + "y" : 69 + }, + { + "drilldown" : "009", + "name" : "#009", + "y" : 68 + }, + { + "drilldown" : "010", + "name" : "#010", + "y" : 60 + }, + { + "drilldown" : "011", + "name" : "#011", + "y" : 78 + }, + { + "y" : 83, + "name" : "#012", + "drilldown" : "012" + }, + { + "y" : 76, + "drilldown" : "013", + "name" : "#013" + }, + { + "y" : 95, + "name" : "#014", + "drilldown" : "014" + }, + { + "y" : 93, + "drilldown" : "015", + "name" : "#015" + }, + { + "drilldown" : "016", + "name" : "#016", + "y" : 66 + }, + { + "y" : 79, + "drilldown" : "017", + "name" : "#017" + }, + { + "drilldown" : "018", + "name" : "#018", + "y" : 76 + }, + { + "name" : "#019", + "drilldown" : "019", + "y" : 95 + }, + { + "drilldown" : "020", + "name" : "#020", + "y" : 95 + }, + { + "name" : "#021", + "drilldown" : "021", + "y" : 67 + }, + { + "name" : "#022", + "drilldown" : "022", + "y" : 63 + }, + { + "drilldown" : "023", + "name" : "#023", + "y" : 91 + }, + { + "y" : 68, + "drilldown" : "024", + "name" : "#024" + }, + { + "drilldown" : "025", + "name" : "#025", + "y" : 44 + } + ] + } + ], + "legend" : { + "enabled" : "false" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } }, "title" : { "text" : "Perl Weekly Challenge Language" }, + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-15 22:53:09 GMT" + }, + "tooltip" : { + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>" + }, "drilldown" : { "series" : [ { + "name" : "001", "data" : [ [ "Perl 5", @@ -30,7 +175,6 @@ 11 ] ], - "name" : "001", "id" : "001" }, { @@ -52,6 +196,8 @@ "id" : "002" }, { + "id" : "003", + "name" : "003", "data" : [ [ "Perl 5", @@ -65,13 +211,9 @@ "Blog", 8 ] - ], - "id" : "003", - "name" : "003" + ] }, { - "name" : "004", - "id" : "004", "data" : [ [ "Perl 5", @@ -85,10 +227,11 @@ "Blog", 9 ] - ] + ], + "name" : "004", + "id" : "004" }, { - "id" : "005", "name" : "005", "data" : [ [ @@ -103,7 +246,8 @@ "Blog", 11 ] - ] + ], + "id" : "005" }, { "data" : [ @@ -124,6 +268,7 @@ "id" : "006" }, { + "name" : "007", "data" : [ [ "Perl 5", @@ -138,12 +283,10 @@ 9 ] ], - "id" : "007", - "name" : "007" + "id" : "007" }, { "id" : "008", - "name" : "008", "data" : [ [ "Perl 5", @@ -157,11 +300,10 @@ "Blog", 11 ] - ] + ], + "name" : "008" }, { - "name" : "009", - "id" : "009", "data" : [ [ "Perl 5", @@ -175,9 +317,13 @@ "Blog", 13 ] - ] + ], + "name" : "009", + "id" : "009" }, { + "id" : "010", + "name" : "010", "data" : [ [ "Perl 5", @@ -191,11 +337,11 @@ "Blog", 11 ] - ], - "name" : "010", - "id" : "010" + ] }, { + "id" : "011", + "name" : "011", "data" : [ [ "Perl 5", @@ -209,13 +355,9 @@ "Blog", 9 ] - ], - "name" : "011", - "id" : "011" + ] }, { - "name" : "012", - "id" : "012", "data" : [ [ "Perl 5", @@ -229,11 +371,11 @@ "Blog", 11 ] - ] + ], + "name" : "012", + "id" : "012" }, { - "name" : "013", - "id" : "013", "data" : [ [ "Perl 5", @@ -247,7 +389,9 @@ "Blog", 13 ] - ] + ], + "name" : "013", + "id" : "013" }, { "id" : "014", @@ -269,7 +413,6 @@ }, { "id" : "015", - "name" : "015", "data" : [ [ "Perl 5", @@ -283,9 +426,11 @@ "Blog", 15 ] - ] + ], + "name" : "015" }, { + "id" : "016", "data" : [ [ "Perl 5", @@ -300,11 +445,9 @@ 12 ] ], - "id" : "016", "name" : "016" }, { - "id" : "017", "name" : "017", "data" : [ [ @@ -319,9 +462,11 @@ "Blog", 12 ] - ] + ], + "id" : "017" }, { + "name" : "018", "data" : [ [ "Perl 5", @@ -336,10 +481,11 @@ 14 ] ], - "id" : "018", - "name" : "018" + "id" : "018" }, { + "id" : "019", + "name" : "019", "data" : [ [ "Perl 5", @@ -353,11 +499,10 @@ "Blog", 13 ] - ], - "id" : "019", - "name" : "019" + ] }, { + "name" : "020", "data" : [ [ "Perl 5", @@ -372,10 +517,10 @@ 13 ] ], - "id" : "020", - "name" : "020" + "id" : "020" }, { + "name" : "021", "data" : [ [ "Perl 5", @@ -390,12 +535,10 @@ 10 ] ], - "id" : "021", - "name" : "021" + "id" : "021" }, { "name" : "022", - "id" : "022", "data" : [ [ "Perl 5", @@ -409,11 +552,10 @@ "Blog", 10 ] - ] + ], + "id" : "022" }, { - "id" : "023", - "name" : "023", "data" : [ [ "Perl 5", @@ -427,11 +569,11 @@ "Blog", 12 ] - ] + ], + "name" : "023", + "id" : "023" }, { - "id" : "024", - "name" : "024", "data" : [ [ "Perl 5", @@ -445,15 +587,16 @@ "Blog", 11 ] - ] + ], + "name" : "024", + "id" : "024" }, { "id" : "025", - "name" : "025", "data" : [ [ "Perl 5", - 21 + 22 ], [ "Perl 6", @@ -463,161 +606,18 @@ "Blog", 7 ] - ] + ], + "name" : "025" } ] }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, "plotOptions" : { "series" : { "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 + "enabled" : 1, + "format" : "{point.y}" }, "borderWidth" : 0 } - }, - "series" : [ - { - "data" : [ - { - "name" : "#001", - "y" : 132, - "drilldown" : "001" - }, - { - "drilldown" : "002", - "y" : 104, - "name" : "#002" - }, - { - "drilldown" : "003", - "y" : 66, - "name" : "#003" - }, - { - "y" : 86, - "name" : "#004", - "drilldown" : "004" - }, - { - "drilldown" : "005", |
