diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-23 18:16:52 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-23 18:16:52 +0100 |
| commit | e2d5e1d6f93b16acdd49d287b638bea5d40f413d (patch) | |
| tree | f80b2198509bd64f86950380ff63206404497eed | |
| parent | dbf1cebdc82b8daf3c2f168bda8cd3aff79fa7d7 (diff) | |
| download | perlweeklychallenge-club-e2d5e1d6f93b16acdd49d287b638bea5d40f413d.tar.gz perlweeklychallenge-club-e2d5e1d6f93b16acdd49d287b638bea5d40f413d.tar.bz2 perlweeklychallenge-club-e2d5e1d6f93b16acdd49d287b638bea5d40f413d.zip | |
- Added solutions by Trenton Langer.
| -rw-r--r-- | challenge-027/trenton-langer/perl5/ch-1.pl | 91 | ||||
| -rw-r--r-- | challenge-027/trenton-langer/perl5/ch-2.pl | 92 | ||||
| -rw-r--r-- | stats/pwc-current.json | 73 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 60 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 258 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 590 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 122 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 92 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 26 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 98 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 290 |
11 files changed, 995 insertions, 797 deletions
diff --git a/challenge-027/trenton-langer/perl5/ch-1.pl b/challenge-027/trenton-langer/perl5/ch-1.pl new file mode 100644 index 0000000000..cef546d440 --- /dev/null +++ b/challenge-027/trenton-langer/perl5/ch-1.pl @@ -0,0 +1,91 @@ +#!/mu/bin/perl -w +use strict; +no warnings; + + + +################################################################################################################################################################## +################################################################################################################################################################## +## Authorship +################################################################################################################################################################## +################################################################################################################################################################## +### Project +############# Perl Weekly Challenge - 027 +### Name +############# c027_t1.pl +### Author +############# Trenton Langer +### Creation Date +############# 20190922 +### Description +############# Intersection of lines from points + + + +##################################################################################################################### +##################################################################################################################### +## PWC - 027 - Task 1 +##################################################################################################################### +##################################################################################################################### +#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. + + + +##################################################################################################################### +##################################################################################################################### +## Solution +##################################################################################################################### +##################################################################################################################### +my ($a, $b, $c, $d) = (0, 0, 10, 10); #x1,y1 , x2,y2 +my ($p, $q, $r, $s) = (0, 10, 10, 0); #x1,y1 , x2,y2 +($a, $b, $c, $d, $p, $q, $r, $s) = @ARGV if(scalar @ARGV == 8); # CMD Line override if given all 8 + +print "Line1:\t($a, $b) to \t($c, $d)\n"; +print "Line2:\t($p, $q) to \t($r, $s)\n"; + +my ($int_x, $int_y) = @{intersection($a, $b, $c, $d, $p, $q, $r, $s)}; +print defined($int_x) ? "Intersection:\t($int_x, $int_y)\n" : "Lines are Parallel\n"; + + + +##################################################################################################################### +##################################################################################################################### +## Subs +##################################################################################################################### +##################################################################################################################### +sub intersection() +{ + my ($line1x1,$line1y1,$line1x2,$line1y2,$line2x1,$line2y1,$line2x2,$line2y2) = @_; + + # Equations - ax + by = c (Standard Form) + my $line1a = $line1y2 - $line1y1; + my $line1b = $line1x1 - $line1x2; + my $line1c = $line1a*($line1x1) + $line1b*($line1y1); + #($line1a,$line1b,$line1c) = (-1*$line1a,-1*$line1b,-1*$line1c) if($line1a < 0); + + my $line2a = $line2y2 - $line2y1; + my $line2b = $line2x1 - $line2x2; + my $line2c = $line2a*($line2x1) + $line2b*($line2y1); + #($line2a,$line2b,$line2c) = (-1*$line2a,-1*$line2b,-1*$line2c) if($line2a < 0); + + # Solve System + ##### a1x + b1y = c1 && a2x + b2y = c2 + ##### Reduce out y terms (mutliply by b1/b2) and subtract equations + ##### (a1b2 - a2b1)x = b2c1 - b1c2 + my $x_factor = $line1a*$line2b - $line2a*$line1b; + return [undef, undef] if($x_factor == 0); # Lines do not intersect + + my $x = ($line2b*$line1c - $line1b*$line2c)/$x_factor; + my $y = ($line1a*$line2c - $line2a*$line1c)/$x_factor; + return [$x, $y]; +} + + + + diff --git a/challenge-027/trenton-langer/perl5/ch-2.pl b/challenge-027/trenton-langer/perl5/ch-2.pl new file mode 100644 index 0000000000..2876c00951 --- /dev/null +++ b/challenge-027/trenton-langer/perl5/ch-2.pl @@ -0,0 +1,92 @@ +#!/mu/bin/perl -w +use strict; +no warnings; + + + +################################################################################################################################################################## +################################################################################################################################################################## +## Authorship +################################################################################################################################################################## +################################################################################################################################################################## +### Project +############# Perl Weekly Challenge - 027 +### Name +############# c027_t2.pl +### Author +############# Trenton Langer +### Creation Date +############# 20190922 +### Description +############# Display of historical data + + + +##################################################################################################################### +##################################################################################################################### +## PWC - 027 - Task 2 +##################################################################################################################### +##################################################################################################################### +#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. + + + +##################################################################################################################### +##################################################################################################################### +## Solution +##################################################################################################################### +##################################################################################################################### +tie my $x, 'HistoricalScalar'; +$x = 10; +$x = 20; +$x -= 5; +untie $x; + + + +##################################################################################################################### +##################################################################################################################### +## Subs +##################################################################################################################### +##################################################################################################################### +package HistoricalScalar; +sub TIESCALAR # obj creation (tie $scalar, 'NAME', args) +{ + my $class = shift; + + my $self; + $self->{_ARRAY} = []; + + return bless $self, $class; +} +sub FETCH # retrieve values +{ + my $self = shift; + return $self->{_ARRAY}->[-1]; +} +sub STORE # stores values +{ + my $self = shift; + my $input = shift; + push @{$self->{_ARRAY}}, $input; +} +sub UNTIE # indicate no longer need tied variable (untie $@%var;) +{ + my $self = shift; + print "History:\n"; + foreach my $val (@{$self->{_ARRAY}}) + { + print "\t->\t$val\n"; + } +} +sub DESTROY # clean up (undef $@%var;) +{ + my $self = shift; +} + + diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 6e0499ec93..4cecdea032 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -4,29 +4,16 @@ "text" : "Total Solutions" } }, - "xAxis" : { - "type" : "category" - }, - "subtitle" : { - "text" : "[Champions: 3] Last updated at 2019-09-23 16:09:22 GMT" - }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "format" : "{point.y}", - "enabled" : 1 - }, - "borderWidth" : 0 - } - }, "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 + "followPointer" : 1, + "pointFormat" : "<span style='color:{point.color}'>{point.name}</span>: <b>{point.y:f}</b><br/>" }, "drilldown" : { "series" : [ { + "id" : "Roger Bell West", + "name" : "Roger Bell West", "data" : [ [ "Perl 5", @@ -36,9 +23,7 @@ "Perl 6", 1 ] - ], - "id" : "Roger Bell West", - "name" : "Roger Bell West" + ] }, { "id" : "Simon Proctor", @@ -54,17 +39,47 @@ "data" : [ [ "Perl 5", + 2 + ] + ], + "name" : "Trenton Langer", + "id" : "Trenton Langer" + }, + { + "data" : [ + [ + "Perl 5", 1 ] ], - "id" : "Yet Ebreo", - "name" : "Yet Ebreo" + "name" : "Yet Ebreo", + "id" : "Yet Ebreo" } ] }, + "chart" : { + "type" : "column" + }, + "plotOptions" : { + "series" : { + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + }, + "borderWidth" : 0 + } + }, + "xAxis" : { + "type" : "category" + }, + "subtitle" : { + "text" : "[Champions: 4] Last updated at 2019-09-23 17:16:33 GMT" + }, + "title" : { + "text" : "Perl Weekly Challenge - 027" + }, "series" : [ { - "colorByPoint" : 1, "data" : [ { "name" : "Roger Bell West", @@ -77,20 +92,20 @@ "name" : "Simon Proctor" }, { + "name" : "Trenton Langer", + "drilldown" : "Trenton Langer", + "y" : 2 + }, + { "drilldown" : "Yet Ebreo", "y" : 1, "name" : "Yet Ebreo" } ], + "colorByPoint" : 1, "name" : "Perl Weekly Challenge - 027" } ], - "title" : { - "text" : "Perl Weekly Challenge - 027" - }, - "chart" : { - "type" : "column" - }, "legend" : { "enabled" : 0 } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 94d89e8d09..3880a87ab7 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -2,21 +2,30 @@ "tooltip" : { "pointFormat" : "<b>{point.y:.0f}</b>" }, - "subtitle" : { - "text" : "Last updated at 2019-09-23 16:09:30 GMT" + "chart" : { + "type" : "column" }, - "xAxis" : { - "type" : "category", - "labels" : { - "style" : { - "fontFamily" : "Verdana, sans-serif", - "fontSize" : "13px" - } + "yAxis" : { + "min" : 0, + "title" : { + "text" : null } }, "series" : [ { "name" : "Contributions", + "dataLabels" : { + "align" : "right", + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "format" : "{point.y:.0f}", + "rotation" : -90, + "y" : 10, + "enabled" : "true", + "color" : "#FFFFFF" + }, "data" : [ [ "Blog", @@ -24,38 +33,29 @@ ], [ "Perl 5", - 1069 + 1071 ], [ "Perl 6", 652 ] - ], - "dataLabels" : { - "enabled" : "true", - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, - "align" : "right", - "format" : "{point.y:.0f}", - "rotation" : -90, - "y" : 10, - "color" : "#FFFFFF" - } + ] } ], + "subtitle" : { + "text" : "Last updated at 2019-09-23 17:16:45 GMT" + }, "legend" : { "enabled" : "false" }, - "yAxis" : { - "title" : { - "text" : null + "xAxis" : { + "labels" : { + "style" : { + "fontSize" : "13px", + "fontFamily" : "Verdana, sans-serif" + } }, - "min" : 0 - }, - "chart" : { - "type" : "column" + "type" : "category" }, "title" : { "text" : "Perl Weekly Challenge Contributions - 2019" diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index 931b9a2dbf..7671caa249 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,31 +1,28 @@ { - "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>" - }, - "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-23 16:09:30 GMT" + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } }, "series" : [ { - "colorByPoint" : "true", "name" : "Perl Weekly Challenge Languages", + "colorByPoint" : "true", "data" : [ { - "y" : 132, + "name" : "#001", "drilldown" : "001", - "name" : "#001" + "y" : 132 }, { - "drilldown" : "002", "name" : "#002", - "y" : 104 + "y" : 104, + "drilldown" : "002" }, { - "name" : "#003", + "y" : 66, "drilldown" : "003", - "y" : 66 + "name" : "#003" }, { "name" : "#004", @@ -33,133 +30,151 @@ "y" : 86 }, { - "drilldown" : "005", "name" : "#005", - "y" : 66 + "y" : 66, + "drilldown" : "005" }, { - "drilldown" : "006", "name" : "#006", + "drilldown" : "006", "y" : 47 }, { + "drilldown" : "007", "y" : 55, - "name" : "#007", - "drilldown" : "007" + "name" : "#007" }, { + "drilldown" : "008", "y" : 69, - "name" : "#008", - "drilldown" : "008" + "name" : "#008" }, { + "y" : 68, "drilldown" : "009", - "name" : "#009", - "y" : 68 + "name" : "#009" }, { - "drilldown" : "010", "name" : "#010", - "y" : 60 + "y" : 60, + "drilldown" : "010" }, { - "drilldown" : "011", "name" : "#011", - "y" : 78 + "y" : 78, + "drilldown" : "011" }, { "y" : 83, - "name" : "#012", - "drilldown" : "012" + "drilldown" : "012", + "name" : "#012" }, { - "y" : 76, "name" : "#013", + "y" : 76, "drilldown" : "013" }, { + "name" : "#014", "y" : 95, - "drilldown" : "014", - "name" : "#014" + "drilldown" : "014" }, { + "drilldown" : "015", "y" : 93, - "name" : "#015", - "drilldown" : "015" + "name" : "#015" }, { - "y" : 66, + "name" : "#016", "drilldown" : "016", - "name" : "#016" + "y" : 66 }, { - "y" : 79, "name" : "#017", - "drilldown" : "017" + "drilldown" : "017", + "y" : 79 }, { "y" : 76, - "name" : "#018", - "drilldown" : "018" + "drilldown" : "018", + "name" : "#018" }, { + "y" : 95, "drilldown" : "019", - "name" : "#019", - "y" : 95 + "name" : "#019" }, { - "drilldown" : "020", "name" : "#020", - "y" : 95 + "y" : 95, + "drilldown" : "020" }, { + "name" : "#021", "y" : 67, - "drilldown" : "021", - "name" : "#021" + "drilldown" : "021" }, { - "drilldown" : "022", "name" : "#022", - "y" : 63 + "y" : 63, + "drilldown" : "022" }, { + "name" : "#023", "y" : 91, - "drilldown" : "023", - "name" : "#023" + "drilldown" : "023" }, { - "y" : 70, + "name" : "#024", "drilldown" : "024", - "name" : "#024" + "y" : 70 }, { + "name" : "#025", "y" : 55, - "drilldown" : "025", - "name" : "#025" + "drilldown" : "025" }, { - "y" : 67, + "name" : "#026", "drilldown" : "026", - "name" : "#026" + "y" : 67 }, { - "name" : "#027", "drilldown" : "027", - "y" : 5 + "y" : 7, + "name" : "#027" } ] } ], - "xAxis" : { - "type" : "category" + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } }, "legend" : { "enabled" : "false" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "subtitle" : { + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-23 17:16:45 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>" + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "type" : "category" + }, + "title" : { + "text" : "Perl Weekly Challenge Language" }, "drilldown" : { "series" : [ @@ -182,6 +197,7 @@ ] }, { + "id" : "002", "name" : "002", "data" : [ [ @@ -196,10 +212,11 @@ "Blog", 9 ] - ], - "id" : "002" + ] }, { + "id" : "003", + "name" : "003", "data" : [ [ "Perl 5", @@ -213,9 +230,7 @@ "Blog", 8 ] - ], - "name" : "003", - "id" : "003" + ] }, { "data" : [ @@ -232,11 +247,10 @@ 9 ] ], - "name" : "004", - "id" : "004" + "id" : "004", + "name" : "004" }, { - "id" : "005", "data" : [ [ "Perl 5", @@ -251,7 +265,8 @@ 11 ] ], - "name" : "005" + "name" : "005", + "id" : "005" }, { "data" : [ @@ -268,8 +283,8 @@ 6 ] ], - "name" : "006", - "id" : "006" + "id" : "006", + "name" : "006" }, { "id" : "007", @@ -290,8 +305,6 @@ ] }, { - "id" : "008", - "name" : "008", "data" : [ [ "Perl 5", @@ -305,7 +318,9 @@ "Blog", 11 ] - ] + ], + "name" : "008", + "id" : "008" }, { "data" : [ @@ -322,10 +337,11 @@ 13 ] ], - "name" : "009", - "id" : "009" + "id" : "009", + "name" : "009" }, { + "name" : "010", "id" : "010", "data" : [ [ @@ -340,11 +356,11 @@ "Blog", 11 ] - ], - "name" : "010" + ] }, { "name" : "011", + "id" : "011", "data" : [ [ "Perl 5", @@ -358,11 +374,9 @@ "Blog", 9 ] - ], - "id" : "011" + ] }, { - "name" : "012", "data" : [ [ "Perl 5", @@ -377,10 +391,10 @@ 11 ] ], + "name" : "012", "id" : "012" }, { - "name" : "013", "data" : [ [ "Perl 5", @@ -395,7 +409,8 @@ 13 ] ], - "id" : "013" + "id" : "013", + "name" : "013" }, { "id" : "014", @@ -416,7 +431,6 @@ ] }, { - "name" : "015", "data" : [ [ "Perl 5", @@ -431,7 +445,8 @@ 15 ] ], - "id" : "015" + "id" : "015", + "name" : "015" }, { "id" : "016", @@ -452,8 +467,6 @@ ] }, { - "id" : "017", - "name" : "017", "data" : [ [ "Perl 5", @@ -467,10 +480,11 @@ "Blog", 12 ] - ] + ], + "name" : "017", + "id" : "017" }, { - "id" : "018", "data" : [ [ "Perl 5", @@ -485,10 +499,12 @@ 14 ] ], - "name" : "018" + "name" : "018", + "id" : "018" }, { "id" : "019", + "name" : "019", "data" : [ [ "Perl 5", @@ -502,10 +518,10 @@ "Blog", 13 ] - ], - "name" : "019" + ] }, { + "id" : "020", "name" : "020", "data" : [ [ @@ -520,12 +536,9 @@ "Blog", 13 ] - ], - "id" : "020" + ] }, { - "id" : "021", - "name" : "021", "data" : [ [ "Perl 5", @@ -539,10 +552,13 @@ "Blog", 10 ] - ] + ], + "id" : "021", + "name" : "021" }, { "id" : "022", + "name" : "022", "data" : [ [ "Perl 5", @@ -556,11 +572,9 @@ "Blog", 10 ] - ], - "name" : "022" + ] }, { - "id" : "023", "data" : [ [ "Perl 5", @@ -575,10 +589,10 @@ 12 ] ], + "id" : "023", "name" : "023" }, { - "id" : "024", "data" : [ [ "Perl 5", @@ -593,11 +607,10 @@ 11 ] ], + "id" : "024", "name" : "024" }, { - "id" : "025", - "name" : "025", "data" : [ [ "Perl 5", @@ -611,9 +624,12 @@ "Blog", 12 ] - ] + ], + "name" : "025", + "id" : "025" }, { + "id" : "026", "name" : "026", "data" : [ [ @@ -628,16 +644,13 @@ "Blog", 7 ] - ], - "id" : "026" + ] }, { - "id" : "027", - "name" : "027", "data" : [ [ "Perl 5", - 3 + 5 ], [ "Perl 6", @@ -647,23 +660,10 @@ "Blog", 0 ] - ] + ], + "name" : "027", + "id" : "027" } ] - }, - "plotOptions" : { - "series" : { - "borderWidth" : 0, - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - } - } - }, - "title" : { - "text" : "Perl Weekly Challenge Language" - }, - "chart" : { - "type" : "column" } } diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 3519d164fc..ec4b335fcb 100644 --- a/stats/pwc-leaders.json +++ b/stats/pwc-leaders.json @@ -1,114 +1,140 @@ { - "xAxis" : { - "type" : "category" + "subtitle" : { + "text" : "Click the columns to drilldown the score breakdown. Last updated at 2019-09-23 17:16:42 GMT" + }, + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + } + } + }, + "chart" : { + "type" : "column" + }, + "title" : { + "text" : "Perl Weekly Challenge Leaders (TOP 50)" + }, + "yAxis" : { + "title" : { + "text" : "Total Score" + } + }, + "tooltip" : { + "followPointer" : "true", + "pointFormat" : "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:f}</b><br/>", + "headerFormat" : "<span style=\"font-size:11px\"></span>" }, "drilldown" : { "series" : [ { "name" : "Laurent Rosenfeld", + "id" : "Laurent Rosenfeld", "data" : [ [ + "Blog", + 56 + ], + [ "Perl 5", 52 ], [ "Perl 6", 51 - ], - [ - "Blog", - 56 ] - |
