On Tue, Sep 21, 2010 at 12:19 AM, Alf P. Steinbach /Usenet < alf.p.steinbach+use...@gmail.com <alf.p.steinbach%2buse...@gmail.com>>wrote:
> Uhm, thinking about it (it must have been my unconscious mind doing the > work, it just popped into my head), if you first sort each individual > equivalence relation so that you never have e.g. C=A but only A=C and so on, > and then sort the list of equivalences, then it should reduce to walking the > list and just starting a new set whenever a symbol is encountered that isn't > yet in a set. > This won't work for all inputs. Consider the input: [('a', 'd'), ('b', 'c'), ('c', 'd')] Expected Output: 1, a 1, b 1, c 1, d Actual Output: 1, a 1, d 2, c 2, b 2, d Cheers, Ian
-- http://mail.python.org/mailman/listinfo/python-list