Continues from previous week.
Feel free to submit a merge request or open a ticket if you found any issues with this post. We highly appreciate and welcome your feedback.
Start with the submission by Duncan C White. His solution was the only one with visualization through Gnuplot. For those who want to try it out, you can test using the sample command below. While the plot was a good way look at the intersection graphically (alternatively, read the blog post by Arne Sommer), it doesn’t handle all test data correctly, especially the test cases from E. Choroba.
$ perl ch-1.pl 1 4 4 2 2 4 1 1 a=1, b=4, c=4, d=2, p=2, q=4, r=1, s=1 line 1 : y = -0.666666666666667 x + 4.66666666666667 line 2 : y = 3 x + -2 intersection at (1.81818181818182,3.45454545454546) show results in gnuplot? y
Next, study the solution by Joelle Maslak which was very comprehensive. The solution demonstrated different features of Perl 5 like method signatures, Unicode support, Object-oriented programming through Moose, and well-written comment explaining the solution.
For this task, the participant needs to handle many command line arguments and we’ve observed different ways of doing it in Perl. The common approach was just expanding these command line arguments into argument list as seen in the solution by Duane Powell, Laurent Rosenfeld, Roger Bell_West (using
shift), Lubos Kolouch, and Joelle Maslak. Or if you prefer array slicing as used by Adam Russell, Yet Ebreo and Duncan C White
Special mention of Andrezgz, which provides us with clear instruction on how to pass arguments to its console app. Likewise for Colin Crain which have far more complex but tasteful way to handle co-ordinates as well as validation.
CPAN modules used:
This was one of those task where participants really demonstrated different Perl features or CPAN modules to solve a problem.
Start with the solution by Duane Powell as we learned about basic OO usage in Perl without any external CPAN modules dependencies. Follow this by the solution by Colin Crain and Joelle Maslak. Both share some similarities but using external dependencies and conventional naming conventions.
And then there were those who’ve chosen to implement something similar using
tie but without using the
Tie::Scalar CPAN module. Trenton Langer, Yet Ebreo and Joelle Maslak were the three participants who experimented with such method.
These were the participants that preferred unorthodox aproaches.
Laurent Rosenfeld used a simple yet powerful programming language feature, Closure in Perl to implement logging. This was also a good approach as Closure allows us to keep track of variables that gone out of the scope.
Lastly, the participant that always willing to try and explore different approach, Adam Russell took it to another level by logging through source filter. Read his blog post on how he implemented this.
(1) Historical Intersection with Perl 6 by Arne Sommer
(2) Perl Weekly Challenge 027 by Adam Russell
(3) Perl Weekly Challenge 27: Intersection Point and Historical Values by Laurent Rosenfeld
(4) RogerBW’s Blog: Perl Weekly Challenge 27 by Roger Bell_West