[Purdue-pm] Perl Challenge 018

Mark Senn mark at purdue.edu
Sun Jul 28 20:33:21 PDT 2019


My blog about Perl Weekly Challenge - 018 is at
    https://engineering.purdue.edu/~mark/pwc-018.pdf

It contains the two task descriptions and my Perl 6 (Perl 5 completely
redesigned and rewritten from the ground up, even code as simple as
$array[1] = 1 doesn't work now---but it is worth it---Perl 6 is a
much better language) code to solve the problems.

I quote Jeff Atwood's "The Best Code is No Code At All" and Randall
Munroe's xkcd comic strip because many of the solutions to the
challenges are way over-engineered.

Task #1: print the longest common substring in two or more substrings.
Answer highlights: Put all substrings for word[i] in set[i] and use
Perl 6's set intersection hyperoperator to find the longest substring.

Task #2: implement priority queues.  Answer doesn't use classes or
methods I had to write.  Just two parallel arrays.

First get it working and if needed, then make it better.  And because
the specs for the problems don't give any info about space or time
constraints there is no need to make it better.

-mark


More information about the Purdue-pm mailing list