[Python] alternative for itertools.combinations for about 45 variables?

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have a dictionary of party members, i need to find the number of valid parties available. For checking the valid parties available i have a seperate function. I need to find the number of unique combinations i get from the said dictionary and use it to check if they're valid. The keys of people dictionary are stored as a string. here's the code:

    from itertools import combinations
    # Test_function checks if the party is valid or not, people is the name of the dictionary which has the party members in it
    def valid_parties(people, size, test_function):
    # This takes too long to compute is there any alternative to this
    party_combinations = set(list(combinations(people,size)))
    for i in party_combinations:
    print(party_combinations)
    # call the function valid_parties

    Continue reading...

Compartilhe esta Página