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.
We’re going to review thing a bit differently for this week by listing down all the CPAN modules used for a particular task. The modules usage reflects three things, the coding style of a participant (
Function::Parameters) the common used module (
Math::Prime::Util) to solve a particular problem, and the trend of module usage (
Modern::Perl) which was seen quite often in the last few challenges.
Participants (Mark Anderson, Gustavo Chaves, Guillermo Ramos, Andrezgz, E Choroba, and Joelle Maslak) whose solutions that can be turned into Perl one-liner (well, Jaldhar H. Vyas did it) due to the expressiveness of the regex and brevity of the code. Example of such approach was the solution by Gustavo Chaves as shown below. Note that
$& is the variable that stores the matched string of the regex.
my $string = shift or die "Usage: $0 STRING\n"; say $& while $string =~ /(.)\g1*/g
Generally, the regex used (read up the good breakdown of the regex by Veesh Goodman and Mark Senn) to split and group these characters were quite similar. The difference and difficulty was on how to process the regex result. Roger Bell West used of
pairmap function in his solution was quite unique as well.
Instead of using regex, some participants like Adam Russell, Duane Powell, Dave Jacoby, Daniel Mantovani, Ruben Westerberg, Lubos Kolouch, Pete Houston opted for non-regex approach. Longer code but with increased readability.
For a comparison between the two approaches within a solution, look into the submission by Feng Chang.
The CPAN modules used for this task were
integer (one of the Perl pragma or pragmatic modules).
For a mathematical background of this task, read the excellent write-up by Damian Conway.
As this task involved prime numbers, some participants have re-used (Adam Russell and Jaldhar H. Vyas) their solutions in previous tasks for primality test. Others were using the available function from CPAN modules to find the factors of a number.
For this week, Adam Russell again try another unconventional approach by generating the Amicable numbers using the power of threading. Read his note on using threads in either Perl 5 and Perl 6. We observed more and more participants were solving challenges in both Perl versions these days.
Our regular participant to this task, Joelle Maslak was the only participant again with both Perl 5 and Perl 6 solutions. While both answers looks somewhat similar, the Perl 6 version looks more cleaner due to all the default and built-in features available in Perl 6 and Cro libraries.
For those who haven’t done this task before, do give it a try.
Some write-ups by the regular participants.
(1) Solving two problems by Veesh Goldman
(2) Amicable Split with Perl 6 by Arne Sommer
(3) Perl Weekly Challenge - 020, Task #1 by Mark Senn
(4) Perl Weekly Challenge 020 by Adam Russell
(5) Perl Weekly Challenge - Week 20 by Dave Jacoby
(6) Perl Weekly Challenge # 20: Split String on Character Change and Amicable Numbers by Laurent Rosenfeld
(7) Perl Weekly Challenge: Week 20 by Jaldhar H. Vyas
(8) Perl Weekly Challenge 020: Split on change + amicable numbers by E. Choroba
(9) With friends like these… by Damian Conway