Compare tuples of different lenght

Chris Rebert clp2 at rebertia.com
Sat Aug 20 04:45:04 EDT 2011


On Sat, Aug 20, 2011 at 1:25 AM, Jurgens de Bruin <debruinjj at gmail.com> wrote:
> Hi,
>
> I have a list of tuples:
>
> [(2,),(12,13),(2,3,4),(8,),(5,6),(7,8,9),]
>
> I would like to compare all the tuples to each other and if one
> element if found two tuples the smallest tuples is removed from the
> list.

So, would [(5,6), (6,7,8)] become [(6,7,8)] ?

If no, then I believe you're trying to solve the set covering problem:
http://en.wikipedia.org/wiki/Set_cover_problem

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list