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

The updated code does not work for  @a = qw(a b c d); @b = qw(a b x b c d). It prints a b c d. The output is suprising for me - I created the inputs to catch another kind of mistake. I believe you can't do it in one sweep.

Replies are listed 'Best First'.
Re: Re: Re: Finding largest common subset in lists?
by broquaint (Abbot) on Jun 05, 2003 at 12:58 UTC
    The output is due to the fact that 'b' is repeated in @b so the offset in %map is for the second 'b'. I think I'll leave the code as it is for the time being and just add a caveat that it won't work when there are duplicates in @b. Thanks once again :)

    _________
    broquaint

      It was aimed at duplicates, but I did not take into account the details - just the general algorithm. I believe you can not do it in one sweep when there are duplicates.