|We don't bite newbies here... much|
longest common substring (with needed tweaks)by R56 (Acolyte)
|on Oct 26, 2013 at 16:26 UTC||Need Help??|
R56 has asked for the
wisdom of the Perl Monks concerning the following question:
I have to make a script for the longest common substring. Since it's a 'known' problem, I searched around for a bit and stumbled across the algorithm:
Works like a charm for a simple comparison between two predetermined strings, but my implementation requires a few tweaks:
Instead of only two predetermined strings, it has to read and compare from a previously input-fed array.
Use two limits that are already on the input. The first line of the input contains two numbers. First one tells us how many strings we should consider, second one tells us the minimum number of original strings where the substring should appear. The rest of the lines are the strings for comparison.
I'm handling the beginning like so:
So how could I make the other changes?
Thanks for helping!