On Fri, Sep 4, 2015 at 7:28 AM, marcus lütolf <marcus.luet...@bluewin.ch>
wrote:

> I should probably tell you the real task are a series (maximum ~ 301)
> lists in which real names  of people are assigned to the items/letters for
> 2 people(golfers) can be in  the same list(flight)  only once for an
> extended period of time.
> The next step would be to assign compatible and noncompatible attributes
> to the items/letters which will reduce the maximum of possible
> lists(flights)
>
>
I came up with this (obviously it could be made shorter, but I thought it
would be clearer this way):

import string, itertools

def main():
    validCombos = []
    usedPairs = []
    allCombos = itertools.combinations(string.ascii_lowercase, 3)
    for combo in allCombos:
        pair1 = (combo[0],combo[1])
        pair2 = (combo[0],combo[2])
        pair3 = (combo[1],combo[2])
        if pair1 in usedPairs or pair2 in usedPairs or pair3 in usedPairs:
            next
        else:
            usedPairs.append(pair1)
            usedPairs.append(pair2)
            usedPairs.append(pair3)
            validCombos.append(combo)
    print(validCombos)
    print(len(validCombos))
if __name__ == '__main__':
    main()


The resulting triplets seem to meet your criteria - but there are only 90
of them.  How confident are you about the number 301?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to