diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-29 09:35:00 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-29 09:35:00 +0100 |
| commit | 63cb54e6fce5c7128ed5d05f94c76bc333ffaa60 (patch) | |
| tree | e388dc004457f63c1618be984df5fb53d6b687f7 | |
| parent | 6d1910afd271caaac2fd6c601cdf7850dc858451 (diff) | |
| download | perlweeklychallenge-club-63cb54e6fce5c7128ed5d05f94c76bc333ffaa60.tar.gz perlweeklychallenge-club-63cb54e6fce5c7128ed5d05f94c76bc333ffaa60.tar.bz2 perlweeklychallenge-club-63cb54e6fce5c7128ed5d05f94c76bc333ffaa60.zip | |
- Added solutions by Colin Crain.
| -rw-r--r-- | challenge-027/colin-crain/perl5/HistoryThing.pm | 49 | ||||
| -rw-r--r-- | challenge-027/colin-crain/perl5/ch-1.pl | 68 | ||||
| -rw-r--r-- | challenge-027/colin-crain/perl5/ch-2.pl | 56 | ||||
| -rw-r--r-- | stats/pwc-current.json | 155 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 52 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 414 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 534 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 32 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 102 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 34 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 44 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 284 |
12 files changed, 1006 insertions, 818 deletions
diff --git a/challenge-027/colin-crain/perl5/HistoryThing.pm b/challenge-027/colin-crain/perl5/HistoryThing.pm new file mode 100644 index 0000000000..163478de2f --- /dev/null +++ b/challenge-027/colin-crain/perl5/HistoryThing.pm @@ -0,0 +1,49 @@ +# HistoryThing +# +# object +# +# +# (c) 2019 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +package HistoryThing; + +use Moo; +use feature ":5.26"; +our $VERSION = "0.01"; + + +## attributes +has 'x' => ( + is => 'rw', + trigger => sub { + my ($self, $new) = @_; + push $self->_history->{'x'}->@*, $new; + } +); + +has 'y' => ( + is => 'rw', + trigger => sub { + my ($self, $new) = @_; + push $self->_history->{'y'}->@*, $new; + } +); + +## pubic methods +sub get_hist { + my ($self, $var) = @_; + return (join ', ', $self->_history->{$var}->@*); + +}; + +## private attribute (hash) +has _history => ( + is => 'rw', + default => sub { + return { 'x' => [], 'y' => [] }; + }, +); + + +1; diff --git a/challenge-027/colin-crain/perl5/ch-1.pl b/challenge-027/colin-crain/perl5/ch-1.pl new file mode 100644 index 0000000000..fb1df3b6f0 --- /dev/null +++ b/challenge-027/colin-crain/perl5/ch-1.pl @@ -0,0 +1,68 @@ +#! /opt/local/bin/perl +# +# intersection.pl +# +# task: Write a script to find the intersection of two straight +# lines. The co-ordinates of the two lines should be provided +# as command line parameter. For example: +# The two ends of Line 1 are represented as co-ordinates (a,b) and (c,d). +# The two ends of Line 2 are represented as co-ordinates (p,q) and (r,s). +# The script should print the co-ordinates of point of intersection of the above two lines. +# +# usage: ./intersection.pl '(1,1)' '(6,6)' '(0,6)' '(6,0)' +# +# V3 +# +# 2019 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +use Getopt::Long; + +use warnings; +use strict; +use feature ":5.26"; + +## ## ## ## ## MAIN + + +my $line1; +my $line2; + +GetOptions( 'line1=s' => \$line1, + 'line2=s' => \$line2 +) or die "error with GetOptions: $!"; + +my (@x, @y); +if ( $line1 =~ / ([ - \d ]+) # some digits, the x coordinate + [ \s , ]+ # a combination of comma and spaces + ([ - \d ]+) # some digits, the y coordinate + [^ - \d ]+ # parens, spaces, commas or whatnot between pairs + ([ - \d ]+) # some digits, the x coordinate + [ \s , ]+ # a combination of comma and spaces + ([ - \d ]+) # some digits, the y coordinate + /xx) { + @x = ($1, $3); + @y = ($2, $4); +} +if ( $line2 =~ /([-\d]+) [\s,]+ ([-\d]+) [^-\d]+ ([-\d]+) [\s,]+ ([-\d]+)/x ) { ## same regex as above + push @x, ($1, $3); + push @y, ($2, $4); +} + +## if we didn't load 4 points bail out +for (0..3) { + if (! defined $x[$_] or not defined $y[$_]) { + die "improper input\nusage: ./intersection3.pl --line1 '(a,b) (c,d)' --line2 '(q,r) (s,t)'\n" + } +} + +## extract the intersection using linear algebra determinate +my $det_x_num = (($x[0] * $y[1] - $y[0] * $x[1]) * ($x[2] - $x[3])) - (($x[0] - $x[1]) * ($x[2] * $y[3] - $y[2] * $x[3])); +my $det_y_num = (($x[0] * $y[1] - $y[0] * $x[1]) * ($x[2] - $x[3])) - (($y[0] - $y[1]) * ($x[2] * $y[3] - $y[2] * $x[3])); +my $det_div = (($x[0] - $x[1]) * ($y[2] - $y[3])) - (($y[0] - $y[1]) * ($x[2] - $x[3])); + +my ($px, $py) = ($det_x_num/$det_div, $det_y_num/$det_div); + +say "\($px, $py\)"; + + diff --git a/challenge-027/colin-crain/perl5/ch-2.pl b/challenge-027/colin-crain/perl5/ch-2.pl new file mode 100644 index 0000000000..c3484a0303 --- /dev/null +++ b/challenge-027/colin-crain/perl5/ch-2.pl @@ -0,0 +1,56 @@ +#! /opt/local/bin/perl +# HistoryThing.pl +# +# task: Write a script that allows you to capture/display +# historical data. It could be an object or a scalar. +# For example +# +# my $x = 10; $x = 20; $x -= 5; +# +# After the above operations, it should list $x historical value in order. +# +# method: in the script below, with its related package, h is an object that holds +# two values, x and y. The name and number of values is easily extendable. +# Altering the values for either variable results in the new value recorded +# to a historical list of values that is maintained and can be viewed by +# calling the 'history' method with the name of the variable in question. +# +# uses a moo object. I like moo. +# +# (c) 2019 colin crain +## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## + +use lib '.'; ## park HistoryThing.pm alongside + +use HistoryThing; + +use warnings; +use strict; +use feature ":5.26"; + +## ## ## ## ## MAIN + +my $h = new HistoryThing; + +## set some values for x +$h->x(1); +say "x at start: ", $h->x; + +$h->x(2); +$h->x(-1); +$h->x('foo'); +say "x is currently: ", $h->x; + +## set some values for y +$h->y(3); +say "y at start: ", $h->y; + +$h->y(4); +$h->y(-5); +$h->y('bar'); +say "y is currently: ", $h->y; + +say "history of x: ", $h->get_hist('x'); +say "history of y: ", $h->get_hist('y'); + + diff --git a/stats/pwc-current.json b/stats/pwc-current.json index eb836c6c81..8251197308 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,36 +1,55 @@ { - "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/>" + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "Perl Weekly Challenge - 027" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, + "subtitle" : { + "text" : "[Champions: 14] Last updated at 2019-09-29 08:34:39 GMT" + }, + "legend" : { + "enabled" : 0 }, "chart" : { "type" : "column" }, "series" : [ { - "name" : "Perl Weekly Challenge - 027", - "colorByPoint" : 1, "data" : [ { - "y" : 2, "drilldown" : "Andrezgz", - "name" : "Andrezgz" + "name" : "Andrezgz", + "y" : 2 + }, + { + "drilldown" : "Colin Crain", + "name" : "Colin Crain", + "y" : 2 }, { - "drilldown" : "Duane Powell", "name" : "Duane Powell", + "drilldown" : "Duane Powell", "y" : 2 }, { - "y" : 2, "drilldown" : "E. Choroba", - "name" : "E. Choroba" + "name" : "E. Choroba", + "y" : 2 }, { - "name" : "Joelle Maslak", + "y" : 2, "drilldown" : "Joelle Maslak", - "y" : 2 + "name" : "Joelle Maslak" }, { "drilldown" : "Kevin Colyer", @@ -38,38 +57,38 @@ "y" : 2 }, { + "y" : 2, "drilldown" : "Lubos Kolouch", - "name" : "Lubos Kolouch", - "y" : 2 + "name" : "Lubos Kolouch" }, { - "y" : 1, "drilldown" : "Mark Anderson", - "name" : "Mark Anderson" + "name" : "Mark Anderson", + "y" : 1 }, { - "y" : 2, + "drilldown" : "Markus Holzer", "name" : "Markus Holzer", - "drilldown" : "Markus Holzer" + "y" : 2 }, { - "drilldown" : "Noud", + "y" : 2, "name" : "Noud", - "y" : 2 + "drilldown" : "Noud" }, { "y" : 3, - "drilldown" : "Roger Bell West", - "name" : "Roger Bell West" + "name" : "Roger Bell West", + "drilldown" : "Roger Bell West" }, { + "y" : 2, "name" : "Simon Proctor", - "drilldown" : "Simon Proctor", - "y" : 2 + "drilldown" : "Simon Proctor" }, { - "drilldown" : "Trenton Langer", "name" : "Trenton Langer", + "drilldown" : "Trenton Langer", "y" : 2 }, { @@ -77,14 +96,26 @@ "name" : "Yet Ebreo", "y" : 3 } - ] + ], + "colorByPoint" : 1, + "name" : "Perl Weekly Challenge - 027" } ], "drilldown" : { "series" : [ { + "data" : [ + [ + "Perl 5", + 2 + ] + ], "name" : "Andrezgz", - "id" : "Andrezgz", + "id" : "Andrezgz" + }, + { + "id" : "Colin Crain", + "name" : "Colin Crain", "data" : [ [ "Perl 5", @@ -103,18 +134,18 @@ "name" : "Duane Powell" }, { - "name" : "E. Choroba", - "id" : "E. Choroba", "data" : [ [ "Perl 5", 2 ] - ] + ], + "id" : "E. Choroba", + "name" : "E. Choroba" }, { - "id" : "Joelle Maslak", "name" : "Joelle Maslak", + "id" : "Joelle Maslak", "data" : [ [ "Perl 6", @@ -129,32 +160,32 @@ 2 ] ], - "name" : "Kevin Colyer", - "id" : "Kevin Colyer" + "id" : "Kevin Colyer", + "name" : "Kevin Colyer" }, { + "id" : "Lubos Kolouch", + "name" : "Lubos Kolouch", "data" : [ [ "Perl 5", 2 ] - ], - "id" : "Lubos Kolouch", - "name" : "Lubos Kolouch" + ] }, { + "name" : "Mark Anderson", + "id" : "Mark Anderson", "data" : [ [ "Perl 5", 1 ] - ], - "id" : "Mark Anderson", - "name" : "Mark Anderson" + ] }, { - "name" : "Markus Holzer", "id" : "Markus Holzer", + "name" : "Markus Holzer", "data" : [ [ "Perl 6", @@ -187,28 +218,26 @@ ] }, { - "name" : "Simon Proctor", - "id" : "Simon Proctor", "data" : [ [ "Perl 6", 2 ] - ] + ], + "id" : "Simon Proctor", + "name" : "Simon Proctor" }, { - "id" : "Trenton Langer", - "name" : "Trenton Langer", "data" : [ [ "Perl 5", 2 ] - ] + ], + "id" : "Trenton Langer", + "name" : "Trenton Langer" }, { - "name" : "Yet Ebreo", - "id" : "Yet Ebreo", "data" : [ [ "Perl 5", @@ -218,34 +247,20 @@ "Perl 6", 1 ] - ] + ], + "name" : "Yet Ebreo", + "id" : "Yet Ebreo" } ] }, - "xAxis" : { - "type" : "category" - }, - "title" : { - "text" : "Perl Weekly Challenge - 027" - }, - "legend" : { - "enabled" : 0 - }, - "subtitle" : { - "text" : "[Champions: 13] Last updated at 2019-09-29 04:32:21 GMT" + "tooltip" : { + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>", + "followPointer" : 1, + "headerFormat" : "<span style='font-size:11px'>{series.name}</span><br/>" }, "yAxis" : { "title" : { "text" : "Total Solutions" } - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 4eff6a64d8..870d7921e1 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,9 +1,21 @@ { + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" + }, + "subtitle" : { + "text" : "Last updated at 2019-09-29 08:34:52 GMT" + }, + "chart" : { + "type" : "column" + }, "legend" : { "enabled" : "false" }, - "subtitle" : { - "text" : "Last updated at 2019-09-29 04:32:33 GMT" + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 }, "xAxis" : { "labels" : { @@ -14,12 +26,11 @@ }, "type" : "category" }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" + "title" : { + "text" : "Perl Weekly Challenge Contributions - 2019" }, "series" : [ { - "name" : "Contributions", "data" : [ [ "Blog", @@ -27,7 +38,7 @@ ], [ "Perl 5", - 1081 + 1083 ], [ "Perl 6", @@ -35,29 +46,18 @@ ] ], "dataLabels" : { - "enabled" : "true", "format" : "{point.y:.0f}", - "color" : "#FFFFFF", + "rotation" : -90, "align" : "right", + "y" : 10, + "enabled" : "true", "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" }, - "y" : 10, - "rotation" : -90 - } + "color" : "#FFFFFF" + }, + "name" : "Contributions" } - ], - "title" : { - "text" : "Perl Weekly Challenge Contributions - 2019" - }, - "chart" : { - "type" : "column" - }, - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - } + ] } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index c0f61f1a31..bdeb959f01 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,11 +1,156 @@ { - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 + "series" : [ + { + "name" : "Perl Weekly Challenge Languages", + "colorByPoint" : "true", + "data" : [ + { + "name" : "#001", + "drilldown" : "001", + "y" : 132 + }, + { + "y" : 104, + "name" : "#002", + "drilldown" : "002" + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 66 + }, + { + "name" : "#004", + "drilldown" : "004", + "y" : 86 + }, + { + "name" : "#005", + "drilldown" : "005", + "y" : 66 + }, + { + "name" : "#006", + "drilldown" : "006", + "y" : 47 + }, + { + "y" : 55, + "drilldown" : "007", + "name" : "#007" + }, + { + "name" : "#008", + "drilldown" : "008", + "y" : 69 + }, + { + "name" : "#009", + "drilldown" : "009", + "y" : 68 + }, + { + "y" : 60, + "drilldown" : "010", + "name" : "#010" + }, + { + "y" : 78, + "drilldown" : "011", + "name" : "#011" + }, + { + "y" : 83, + "name" : "#012", + "drilldown" : "012" + }, + { + "name" : "#013", + "drilldown" : "013", + "y" : 76 + }, + { + "drilldown" : "014", + "name" : "#014", + "y" : 95 + }, + { + "y" : 93, + "name" : "#015", + "drilldown" : "015" + }, + { + "drilldown" : "016", + "name" : "#016", + "y" : 66 + }, + { + "drilldown" : "017", + "name" : "#017", + "y" : 79 + }, + { + "drilldown" : "018", + "name" : "#018", + "y" : 76 + }, + { + "y" : 95, + "drilldown" : "019", + "name" : "#019" + }, + { + "name" : "#020", + "drilldown" : "020", + "y" : 95 + }, + { + "y" : 67, + "name" : "#021", + "drilldown" : "021" + }, + { + "y" : 63, + "name" : "#022", + "drilldown" : "022" + }, + { + "y" : 91, + "name" : "#023", + "drilldown" : "023" + }, + { + "y" : 70, + "name" : "#024", + "drilldown" : "024" + }, + { + "y" : 55, + "name" : "#025", + "drilldown" : "025" + }, + { + "name" : "#026", + "drilldown" : "026", + "y" : 67 + }, + { + "name" : "#027", + "drilldown" : "027", + "y" : 27 + } + ] + } + ], + "title" : { + "text" : "Perl Weekly Challenge Language" + }, + "xAxis" : { + "type" : "category" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" } }, "drilldown" : { @@ -47,8 +192,6 @@ "id" : "002" }, { - "name" : "003", - "id" : "003", "data" : [ [ "Perl 5", @@ -62,9 +205,13 @@ "Blog", 8 ] - ] + ], + "id" : "003", + "name" : "003" }, { + "name" : "004", + "id" : "004", "data" : [ [ "Perl 5", @@ -78,11 +225,10 @@ "Blog", 9 ] - ], - "id" : "004", - "name" : "004" + ] }, { + "id" : "005", "data" : [ [ "Perl 5", @@ -97,11 +243,11 @@ 11 ] ], - "id" : "005", "name" : "005" }, { "name" : "006", + "id" : "006", "data" : [ [ "Perl 5", @@ -115,11 +261,9 @@ "Blog", 6 ] - ], - "id" : "006" + ] }, { - "id" : "007", "data" : [ [ "Perl 5", @@ -134,9 +278,11 @@ 9 ] ], + "id" : "007", "name" : "007" }, { + "id" : "008", "data" : [ [ "Perl 5", @@ -151,10 +297,10 @@ 11 ] ], - "id" : "008", "name" : "008" }, { + "name" : "009", "data" : [ [ "Perl 5", @@ -169,8 +315,7 @@ 13 ] ], - "id" : "009", - "name" : "009" + "id" : "009" }, { "name" : "010", @@ -191,6 +336,8 @@ ] }, { + "name" : "011", + "id" : "011", "data" : [ [ "Perl 5", @@ -204,13 +351,9 @@ "Blog", 9 ] - ], - "id" : "011", - "name" : "011" + ] }, { - "name" : "012", - "id" : "012", "data" : [ [ "Perl 5", @@ -224,11 +367,11 @@ "Blog", 11 ] - ] + ], + "id" : "012", + "name" : "012" }, { - "name" : "013", - "id" : "013", "data" : [ [ "Perl 5", @@ -242,10 +385,11 @@ "Blog", 13 ] - ] + ], + "id" : "013", + "name" : "013" }, { - "name" : "014", "data" : [ [ "Perl 5", @@ -260,10 +404,12 @@ 14 ] ], - "id" : "014" + "id" : "014", + "name" : "014" }, { "name" : "015", + "id" : "015", "data" : [ [ "Perl 5", @@ -277,10 +423,11 @@ "Blog", 15 ] - ], - "id" : "015" + ] }, { + "name" : "016", + "id" : "016", "data" : [ [ "Perl 5", @@ -294,12 +441,10 @@ "Blog", 12 ] - ], - "id" : "016", - "name" : "016" + ] }, { - "name" : "017", + "id" : "017", "data" : [ [ "Perl 5", @@ -314,7 +459,7 @@ 12 ] ], - "id" : "017" + "name" : "017" }, { "data" : [ @@ -335,7 +480,6 @@ "name" : "018" }, { - "name" : "019", "id" : "019", "data" : [ [ @@ -350,9 +494,11 @@ "Blog", 13 ] - ] + ], + "name" : "019" }, { + "id" : "020", "data" : [ [ "Perl 5", @@ -367,11 +513,10 @@ 13 ] ], - "id" : "020", "name" : "020" }, { - "id" : "021", + "name" : "021", "data" : [ [ "Perl 5", @@ -386,9 +531,11 @@ 10 ] ], - "name" : "021" + "id" : "021" }, { + "name" : "022", + "id" : "022", "data" : [ [ "Perl 5", @@ -402,11 +549,10 @@ "Blog", 10 ] - ], - "id" : "022", - "name" : "022" + ] }, { + "name" : "023", "id" : "023", "data" : [ [ @@ -421,11 +567,9 @@ "Blog", 12 ] - ], - "name" : "023" + ] }, { - "id" : "024", "data" : [ [ "Perl 5", @@ -440,6 +584,7 @@ 11 ] ], + "id" : "024", "name" : "024" }, { @@ -462,7 +607,6 @@ }, { "name" : "026", - "id" : "026", "data" : [ [ "Perl 5", @@ -476,13 +620,15 @@ "Blog", 7 ] - ] + ], + "id" : "026" }, { + "id" : "027", "data" : [ [ "Perl 5", - 15 + 17 ], [ "Perl 6", @@ -493,173 +639,27 @@ 0 ] ], - "id" : "027", "name" : "027" } ] }, - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-29 04:32:33 GMT" - }, - "xAxis" : { - "type" : "category" - }, "legend" : { "enabled" : "false" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } } }, "chart" : { "type" : "column" }, - "series" : [ - { - "colorByPoint" : "true", - "data" : [ - { - "name" : "#001", - "drilldown" : "001", - "y" : 132 - }, - { - "name" : "#002", - "y" : 104, - "drilldown" : "002" - }, - { - "drilldown" : "003", - "y" : 66, - "name" : "#003" - }, - { - "y" : 86, - "drilldown" : "004", - "name" : "#004" - }, - { - "name" : "#005", - "y" : 66, - "drilldown" : "005" - }, - { - "drilldown" : "006", - "y" : 47, - "name" : "#006" - }, - { - "drilldown" : "007", - "y" : 55, - "name" : "#007" - }, - { |
