Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: Finding largest common subset in lists?

by Jenda (Abbot)
on Jun 06, 2003 at 09:32 UTC ( [id://263628]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Finding largest common subset in lists?
in thread Finding largest common subset in lists?

I'm stupid, stupid, stupid. There should be:

.... if ($end > @result) { @result = @a[0..$end-1]; } ...
instead of
... if (--$end > @result) { @result = @a[0..$end]; } ...
The way I have it I'd only update the @result if the newly found list was longer by at least 2 items. The usual off-by-one error :-(

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne

Edit by castaway: Closed small tag in signature

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-20 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found