set partition question

"Martin v. Löwis" martin at v.loewis.de
Sun May 25 16:13:26 EDT 2008


> s0 = set([1])
> s1 = set([1,2])
> s2 = set([2])
> S = set([s0,s1,s2])
> one answer we're searching for is s0 = s1 - s2
> 
> There may be arbitrarily many set elements (denoted by integers
> 1,2,3,...) and arbitrarily many combinations of the elements composing
> the sets s_i (s0, s1, ...). We can use any operation or function which
> takes and returns sets.

In that case, there is always a trivial answer. As I can use any
function which takes and returns sets, and as I shall come up with
a function that returns s0, I just use the following function

def f(s):
   return s0

To compute s0, just invoke f with any other of the sets, and you
will - get s0.

> I think this problem is related to integer partitioning, but it's not
> quite the same.

I think the problem is significantly underspecified. It would be a more
interesting problem if there was a restriction to a few selected set
operations, e.g. union, intersection, difference, and combinations
thereof.

Regards,
Martin



More information about the Python-list mailing list