diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-26 20:17:10 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-09-26 20:17:10 +0100 |
| commit | 383eb02731cdd702a7dd410326681b2bf9f380fa (patch) | |
| tree | b9d1b52a4952b1d7380a0bf02d030b7a238f69cc | |
| parent | 486dfa7faa9c99ced005146e8b0b1a045f1c18ad (diff) | |
| download | perlweeklychallenge-club-383eb02731cdd702a7dd410326681b2bf9f380fa.tar.gz perlweeklychallenge-club-383eb02731cdd702a7dd410326681b2bf9f380fa.tar.bz2 perlweeklychallenge-club-383eb02731cdd702a7dd410326681b2bf9f380fa.zip | |
- Added solutions by Kevin Colyer.
| -rw-r--r-- | challenge-027/kevin-colyer/perl6/ch-1.p6 | 65 | ||||
| -rw-r--r-- | challenge-027/kevin-colyer/perl6/ch-2.p6 | 42 | ||||
| -rw-r--r-- | stats/pwc-current.json | 229 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown-summary.json | 48 | ||||
| -rw-r--r-- | stats/pwc-language-breakdown.json | 404 | ||||
| -rw-r--r-- | stats/pwc-leaders.json | 596 | ||||
| -rw-r--r-- | stats/pwc-summary-1-30.json | 36 | ||||
| -rw-r--r-- | stats/pwc-summary-31-60.json | 118 | ||||
| -rw-r--r-- | stats/pwc-summary-61-90.json | 46 | ||||
| -rw-r--r-- | stats/pwc-summary-91-120.json | 96 | ||||
| -rw-r--r-- | stats/pwc-summary.json | 282 |
11 files changed, 1042 insertions, 920 deletions
diff --git a/challenge-027/kevin-colyer/perl6/ch-1.p6 b/challenge-027/kevin-colyer/perl6/ch-1.p6 new file mode 100644 index 0000000000..f2e3fed76c --- /dev/null +++ b/challenge-027/kevin-colyer/perl6/ch-1.p6 @@ -0,0 +1,65 @@ +#!/usr/bin/perl6 +use v6; + +use Test; + +# 27.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. + +#| Prints intersection point of two lines given as 1,2,3,4 5,6,7,8 +multi MAIN(Str $line1,Str $line2) { + my ($meet,$x,$y,$comment) = intersection(| $line1.split(','), | $line2.split(',')); + say $meet ?? "$x,$y" !! $comment; + exit; +} + +sub intersection($a,$b,$c,$d,$e,$f,$g,$h) { + # line 1 a,b -> c,d + # line 2 e,f -> g,h + + my $m1=($b-$d)/($a-$c); + my $m2=($f-$h)/($e-$g); + + return (False,Nil,Nil,"Do not intersect: lines are parallel") if $m1==$m2; + + # y=dydx1.x-dydx1.a+b == y=dydx2.x-dydx2.e+f + + # x=dydx1.a-b/dydx1 + # wrong worong worng my $x=($m1*$a-$b)/$m1; + + my $x=($f-$b+$m1*$a-$m2*$e)/($m1-$m2); + + my $y=$m2*$x-$m2*$e+$f; + + return (False,Nil,Nil,"Do not intersect: x is not on line 1") if $x < $a < $c or $x > $c > $a; + return (False,Nil,Nil,"Do not intersect: y is not on line 1") if $y < $b < $d or $y > $d > $b; + return (False,Nil,Nil,"Do not intersect: x is not on line 2") if $x < $e < $g or $x > $g > $e; + return (False,Nil,Nil,"Do not intersect: y is not on line 2") if $y < $f < $h or $y > $h > $f; + + return (True,$x,$y,"Lines intersect at $x,$y"); + +} + +multi MAIN('test') { + my ($meet,$x,$y,$comment) = intersection(1,1,3,3, 1,3,3,1); + is $meet,True,"Test A - lines meet"; + is $x,2,"Test A - lines meet - x"; + is $y,2,"Test A - lines meet - y"; + diag $comment; + ($meet,$x,$y,$comment) = intersection(1,1,3,3, 1,2,3,4); + is $meet,False,"Test A - lines meet"; + diag $comment; + ($meet,$x,$y,$comment) = intersection(1,1,3,3, 4,3,6,1); + is $meet,False,"Test A - lines meet"; + diag $comment; + ($meet,$x,$y,$comment) = intersection(1,1,3,3, 1,1,3,3); + is $meet,False,"Test D - lines are parallel"; + + + done-testing; +} diff --git a/challenge-027/kevin-colyer/perl6/ch-2.p6 b/challenge-027/kevin-colyer/perl6/ch-2.p6 new file mode 100644 index 0000000000..dcf793c848 --- /dev/null +++ b/challenge-027/kevin-colyer/perl6/ch-2.p6 @@ -0,0 +1,42 @@ +#!/usr/bin/perl6 +use v6; + +use Test; + +# 27.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. + +# with ideas from https://stackoverflow.com/questions/31665384/how-does-one-write-custom-accessor-methods-in-perl6 +class HistoryInt { + has Int $.x =0 ; + has @.history; + + # overwrite the method the attribute declaration added + method x () is rw { + Proxy.new( + FETCH => -> $ { $!x }, + STORE => -> $, Int $new { + $!x = $new; + @!history.push: $new; + } + ) + } + method History () { + @!history; + } +} + +my $h=HistoryInt.new(); + +$h.x=10; +is $h.History,(10),"list of first op"; +$h.x=20; +is $h.History,(10,20),"list of ops"; +$h.x-=5; +is $h.History,(10,20,15),"list of ops"; + +done-testing; + diff --git a/stats/pwc-current.json b/stats/pwc-current.json index 2473823a32..83ac573e9b 100644 --- a/stats/pwc-current.json +++ b/stats/pwc-current.json @@ -1,59 +1,160 @@ { + "series" : [ + { + "name" : "Perl Weekly Challenge - 027", + "data" : [ + { + "y" : 2, + "drilldown" : "Andrezgz", + "name" : "Andrezgz" + }, + { + "y" : 2, + "drilldown" : "Duane Powell", + "name" : "Duane Powell" + }, + { + "y" : 2, + "name" : "E. Choroba", + "drilldown" : "E. Choroba" + }, + { + "y" : 2, + "name" : "Kevin Colyer", + "drilldown" : "Kevin Colyer" + }, + { + "name" : "Mark Anderson", + "drilldown" : "Mark Anderson", + "y" : 1 + }, + { + "drilldown" : "Noud", + "name" : "Noud", + "y" : 2 + }, + { + "y" : 3, + "drilldown" : "Roger Bell West", + "name" : "Roger Bell West" + }, + { + "y" : 2, + "drilldown" : "Simon Proctor", + "name" : "Simon Proctor" + }, + { + "y" : 2, + "name" : "Trenton Langer", + "drilldown" : "Trenton Langer" + }, + { + "drilldown" : "Yet Ebreo", + "name" : "Yet Ebreo", + "y" : 1 + } + ], + "colorByPoint" : 1 + } + ], + "plotOptions" : { + "series" : { + "borderWidth" : 0, + "dataLabels" : { + "enabled" : 1, + "format" : "{point.y}" + } + } + }, + "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/>" + }, + "title" : { + "text" : "Perl Weekly Challenge - 027" + }, + "subtitle" : { + "text" : "[Champions: 10] Last updated at 2019-09-26 19:16:58 GMT" + }, + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } + }, + "chart" : { + "type" : "column" + }, + "xAxis" : { + "type" : "category" + }, + "legend" : { + "enabled" : 0 + }, "drilldown" : { "series" : [ { - "id" : "Andrezgz", - "name" : "Andrezgz", "data" : [ [ "Perl 5", 2 ] - ] + ], + "name" : "Andrezgz", + "id" : "Andrezgz" }, { + "name" : "Duane Powell", "data" : [ [ "Perl 5", 2 ] ], - "id" : "Duane Powell", - "name" : "Duane Powell" + "id" : "Duane Powell" }, { - "id" : "E. Choroba", "name" : "E. Choroba", "data" : [ [ "Perl 5", 2 ] - ] + ], + "id" : "E. Choroba" + }, + { + "name" : "Kevin Colyer", + "data" : [ + [ + "Perl 6", + 2 + ] + ], + "id" : "Kevin Colyer" }, { "name" : "Mark Anderson", - "id" : "Mark Anderson", "data" : [ [ "Perl 5", 1 ] - ] + ], + "id" : "Mark Anderson" }, { - "id" : "Noud", "name" : "Noud", "data" : [ [ "Perl 6", 2 ] - ] + ], + "id" : "Noud" }, { "id" : "Roger Bell West", - "name" : "Roger Bell West", "data" : [ [ "Perl 5", @@ -63,125 +164,39 @@ "Perl 6", 1 ] - ] + ], + "name" : "Roger Bell West" }, { "name" : "Simon Proctor", - "id" : "Simon Proctor", "data" : [ [ "Perl 6", 2 ] - ] + ], + "id" : "Simon Proctor" }, { "id" : "Trenton Langer", - "name" : "Trenton Langer", "data" : [ [ "Perl 5", 2 ] - ] + ], + "name" : "Trenton Langer" }, { - "name" : "Yet Ebreo", "id" : "Yet Ebreo", "data" : [ [ "Perl 5", 1 ] - ] + ], + "name" : "Yet Ebreo" } ] - }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } - }, - "subtitle" : { - "text" : "[Champions: 9] Last updated at 2019-09-26 11:42:20 GMT" - }, - "legend" : { - "enabled" : 0 - }, - "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" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } - }, - "xAxis" : { - "type" : "category" - }, - "title" : { - "text" : "Perl Weekly Challenge - 027" - }, - "series" : [ - { - "name" : "Perl Weekly Challenge - 027", - "colorByPoint" : 1, - "data" : [ - { - "name" : "Andrezgz", - "y" : 2, - "drilldown" : "Andrezgz" - }, - { - "drilldown" : "Duane Powell", - "y" : 2, - "name" : "Duane Powell" - }, - { - "drilldown" : "E. Choroba", - "y" : 2, - "name" : "E. Choroba" - }, - { - "drilldown" : "Mark Anderson", - "y" : 1, - "name" : "Mark Anderson" - }, - { - "y" : 2, - "name" : "Noud", - "drilldown" : "Noud" - }, - { - "y" : 3, - "name" : "Roger Bell West", - "drilldown" : "Roger Bell West" - }, - { - "y" : 2, - "name" : "Simon Proctor", - "drilldown" : "Simon Proctor" - }, - { - "name" : "Trenton Langer", - "y" : 2, - "drilldown" : "Trenton Langer" - }, - { - "drilldown" : "Yet Ebreo", - "y" : 1, - "name" : "Yet Ebreo" - } - ] - } - ] + } } diff --git a/stats/pwc-language-breakdown-summary.json b/stats/pwc-language-breakdown-summary.json index 68f3d9e11a..ba24a093f2 100644 --- a/stats/pwc-language-breakdown-summary.json +++ b/stats/pwc-language-breakdown-summary.json @@ -1,33 +1,22 @@ { - "yAxis" : { - "title" : { - "text" : null - }, - "min" : 0 - }, - "tooltip" : { - "pointFormat" : "<b>{point.y:.0f}</b>" - }, - "chart" : { - "type" : "column" - }, "legend" : { "enabled" : "false" }, "series" : [ { "dataLabels" : { - "rotation" : -90, - "style" : { - "fontSize" : "13px", - "fontFamily" : "Verdana, sans-serif" - }, "format" : "{point.y:.0f}", - "color" : "#FFFFFF", "y" : 10, + "color" : "#FFFFFF", "enabled" : "true", - "align" : "right" + "style" : { + "fontFamily" : "Verdana, sans-serif", + "fontSize" : "13px" + }, + "align" : "right", + "rotation" : -90 }, + "name" : "Contributions", "data" : [ [ "Blog", @@ -39,18 +28,26 @@ ], [ "Perl 6", - 655 + 657 ] - ], - "name" : "Contributions" + ] } ], - "subtitle" : { - "text" : "Last updated at 2019-09-26 11:42:35 GMT" + "yAxis" : { + "title" : { + "text" : null + }, + "min" : 0 }, "title" : { "text" : "Perl Weekly Challenge Contributions - 2019" }, + "subtitle" : { + "text" : "Last updated at 2019-09-26 19:17:05 GMT" + }, + "chart" : { + "type" : "column" + }, "xAxis" : { "labels" : { "style" : { @@ -59,5 +56,8 @@ } }, "type" : "category" + }, + "tooltip" : { + "pointFormat" : "<b>{point.y:.0f}</b>" } } diff --git a/stats/pwc-language-breakdown.json b/stats/pwc-language-breakdown.json index d9ae6a7afa..23a64e0df1 100644 --- a/stats/pwc-language-breakdown.json +++ b/stats/pwc-language-breakdown.json @@ -1,177 +1,24 @@ { - "series" : [ - { - "data" : [ - { - "name" : "#001", - "y" : 132, - "drilldown" : "001" - }, - { - "name" : "#002", - "y" : 104, - "drilldown" : "002" - }, - { - "y" : 66, - "name" : "#003", - "drilldown" : "003" - }, - { - "y" : 86, - "name" : "#004", - "drilldown" : "004" - }, - { - "y" : 66, - "name" : "#005", - "drilldown" : "005" - }, - { - "y" : 47, - "name" : "#006", - "drilldown" : "006" - }, - { - "name" : "#007", - "y" : 55, - "drilldown" : "007" - }, - { - "name" : "#008", - "y" : 69, - "drilldown" : "008" - }, - { - "drilldown" : "009", - "y" : 68, - "name" : "#009" - }, - { - "name" : "#010", - "y" : 60, - "drilldown" : "010" - }, - { - "name" : "#011", - "y" : 78, - "drilldown" : "011" - }, - { - "drilldown" : "012", - "y" : 83, - "name" : "#012" - }, - { - "name" : "#013", - "y" : 76, - "drilldown" : "013" - }, - { - "y" : 95, - "name" : "#014", - "drilldown" : "014" - }, - { - "name" : "#015", - "y" : 93, - "drilldown" : "015" - }, - { - "y" : 66, - "name" : "#016", - "drilldown" : "016" - }, - { - "drilldown" : "017", - "name" : "#017", - "y" : 79 - }, - { - "drilldown" : "018", - "name" : "#018", - "y" : 76 - }, - { - "drilldown" : "019", - "name" : "#019", - "y" : 95 - }, - { - "drilldown" : "020", - "y" : 95, - "name" : "#020" - }, - { - "y" : 67, - "name" : "#021", - "drilldown" : "021" - }, - { - "y" : 63, - "name" : "#022", - "drilldown" : "022" - }, - { - "drilldown" : "023", - "name" : "#023", - "y" : 91 - }, - { - "name" : "#024", - "y" : 70, - "drilldown" : "024" - }, - { - "drilldown" : "025", - "y" : 55, - "name" : "#025" - }, - { - "drilldown" : "026", - "name" : "#026", - "y" : 67 - }, - { - "y" : 17, - "name" : "#027", - "drilldown" : "027" - } - ], - "colorByPoint" : "true", - "name" : "Perl Weekly Challenge Languages" - } - ], - "xAxis" : { - "type" : "category" - }, "title" : { "text" : "Perl Weekly Challenge Language" }, "subtitle" : { - "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-26 11:42:35 GMT" + "text" : "Click the columns to drilldown the language breakdown. Last updated at 2019-09-26 19:17:05 GMT" }, - "legend" : { - "enabled" : "false" + "xAxis" : { + "type" : "category" }, - "yAxis" : { - "title" : { - "text" : "Total Solutions" - } + "chart" : { + "type" : "column" }, - "plotOptions" : { - "series" : { - "dataLabels" : { - "enabled" : 1, - "format" : "{point.y}" - }, - "borderWidth" : 0 - } + "tooltip" : { + "followPointer" : "true", + "headerFormat" : "<span style=\"font-size:11px\"></span>", + "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>" }, "drilldown" : { "series" : [ { - "name" : "001", "id" : "001", "data" : [ [ @@ -186,9 +33,12 @@ "Blog", 11 ] - ] + ], + "name" : "001" }, { + "name" : "002", + "id" : "002", "data" : [ [ "Perl 5", @@ -202,9 +52,7 @@ "Blog", 9 ] - ], - "id" : "002", - "name" : "002" + ] }, { "name" : "003", @@ -262,7 +110,6 @@ }, { "name" : "006", - "id" : "006", "data" : [ [ "Perl 5", @@ -276,7 +123,8 @@ "Blog", 6 ] - ] + ], + "id" : "006" }, { "id" : "007", @@ -297,7 +145,6 @@ "name" : "007" }, { - "name" : "008", "data" : [ [ "Perl 5", @@ -312,7 +159,8 @@ 11 ] ], - "id" : "008" + "id" : "008", + "name" : "008" }, { "name" : "009", @@ -351,7 +199,6 @@ "id" : "010" }, { - "name" : "011", "data" : [ [ "Perl 5", @@ -366,11 +213,11 @@ 9 ] ], - "id" : "011" + "id" : "011", + "name" : "011" }, { "name" : "012", - "id" : "012", "data" : [ [ "Perl 5", @@ -384,9 +231,11 @@ "Blog", 11 ] - ] + ], + "id" : "012" }, { + "name" : "013", "id" : "013", "data" : [ [ @@ -401,11 +250,9 @@ "Blog", 13 ] - ], - "name" : "013" + ] }, { - "name" : "014", "data" : [ [ "Perl 5", @@ -420,10 +267,10 @@ 14 ] ], - "id" : "014" + "id" : "014", + "name" : "014" }, { - "id" : "015", "data" : [ [ "Perl 5", @@ -438,10 +285,12 @@ 15 ] ], + "id" : "015", "name" : "015" }, { "name" : "016", + "id" : "016", "data" : [ [ "Perl 5", @@ -455,8 +304,7 @@ "Blog", 12 ] - ], - "id" : "016" + ] }, { "name" : "017", @@ -495,6 +343,7 @@ "name" : "018" }, { + "name" : "019", "id" : "019", "data" : [ [ @@ -509,10 +358,10 @@ "Blog", 13 ] - ], - "name" : "019" + ] }, { + "id" : "020", "data" : [ [ "Perl 5", @@ -527,7 +376,6 @@ 13 ] ], - "id" : "020", "name" : "020" }, { @@ -549,7 +397,7 @@ "name" : "021" }, { - "id" : "022", + "name" : "022", "data" : [ [ "Perl 5", @@ -564,7 +412,7 @@ 10 ] ], - "name" : "022" + "id" : "022" }, { "id" : "023", @@ -585,6 +433,7 @@ "name" : "023" }, { + "id" : "024", "data" : [ [ "Perl 5", @@ -599,10 +448,11 @@ 11 ] ], - "id" : "024", "name" : "024" }, { + "name" : "025", + "id" : "025", "data" : [ [ "Perl 5", @@ -616,12 +466,9 @@ "Blog", 12 ] - ], - "id" : "025", - "name" : "025" + ] }, { - "name" : "026", "data" : [ [ "Perl 5", @@ -636,11 +483,10 @@ 7 ] ], - "id" : "026" + "id" : "026", + "name" : "026" }, { - "name" : "027", - "id" : "027", "data" : [ [ "Perl 5", @@ -648,22 +494,176 @@ ], [ "Perl 6", - 5 + 7 ], [ "Blog", 0 ] - ] + ], + "id" : "027", + "name" : "027" } ] }, - "tooltip" : { - "headerFormat" : "<span style=\"font-size:11px\"></span>", - "pointFormat" : "<span style=\"color:{point.color}\">Challenge {point.name}</span>: <b>{point.y:f}</b><br/>", - "followPointer" : "true" + "legend" : { + "enabled" : "false" }, - "chart" : { - "type" : "column" + "plotOptions" : { + "series" : { + "dataLabels" : { + "format" : "{point.y}", + "enabled" : 1 + }, + "borderWidth" : 0 + } + }, + "series" : [ + { + "name" : "Perl Weekly Challenge Languages", + "data" : [ + { + "drilldown" : "001", + "name" : "#001", + "y" : 132 + }, + { + "y" : 104, + "name" : "#002", + "drilldown" : "002" + }, + { + "name" : "#003", + "drilldown" : "003", + "y" : 66 + }, + { + "name" : "#004", + "drilldown" : "004", + "y" : 86 + }, + { + "y" : 66, + "name" : "#005", + "drilldown" : "005" + }, + { + "drilldown" : "006", + "name" : "#006", + "y" : 47 + }, + { + "drilldown" : "007", + "name" : "#007", + "y" : 55 + }, + { + "drilldown" : "008", + "name" : "#008", + "y" : 69 + }, + { + "name" : "#009", + "drilldown" : "009", + "y" : 68 + }, + { + "y" : 60, + "drilldown" : "010", + "name" : "#010" + }, + { + "name" : "#011", + "drilldown" : "011", + "y" : 78 + }, + { + "y" : 83, + "drilldown" : "012", + "name" : "#012" + }, + { + "drilldown" : "013", + "name" : "#013", + "y" : 76 + }, + { + "y" : 95, + "drilldown" : "014", + "name" : "#014" + }, + { + "y" : 93, + "drilldown" : "015", + "name" : "#015" + }, + { + "name" : "#016", + "drilldown" : "016", + "y" : 66 + }, + { + "name" : "#017", + "drilldown" : "017", + "y" : 79 + }, + { + "y" : 76, + "drilldown" : "018", + "name" : "#018" + }, + { + "y" : 95, + "name" : "#019", + "drilldown" : "019" + }, + { + "drilldown" : "020", + "name" : "#020", + "y" : 95 + }, + { + "y" : 67, + "name" : "#021", + "drilldown" : "021" + }, + { + "name" : "#022", + "drilldown" : "022", + "y" : 63 + }, + { + "drilldown" : "023", + "name" : "#023", + "y" : 91 + }, + { + "drilldown" : "024", + "name" : "#024", + "y" : 70 + }, + { + "drilldown" : "025", + "name" : "#025", + "y" : 55 + }, + { + "y" : 67, + "drilldown" : "026", + "name" : "#026" + }, + { + "y" : 19, + "drilldown" : "027", + "name" : "#027" + } + ], + "colorByPoint" : "true" + } + ], + "yAxis" : { + "title" : { + "text" : "Total Solutions" + } } } diff --git a/stats/pwc-leaders.json b/stats/pwc-leaders.json index 2a50a06a91..fad53ec7aa 100644 --- a/stats/pwc-leaders.json +++ b/ |
