## Profil

A rejoint le : 12 mai 2022

## REITEC.PMM Crack For Windows

Author: Version: Status: License: Dependencies: Website: Category: Q: Efficiently creating all possible sets of cards from a list of cards I am writing a python program to create all possible sets of cards (ie, a hand) from a set of cards (the deck). If the player chooses to discard a card, it is removed from the deck. I'm currently using a brute force algorithm like so: def build_hand(self): for hand in range(1,13): hand.append(self.deck.pop(0)) self.build_hand() self.hand = [] self.score = 0 The problem is, I am running into a memory limit as the deck size gets larger. Is there a better way to build all these hands? Is there an algorithm that can solve this efficiently? I am using python 3.2.3 Thanks! A: You can use itertools.permutations and a generator to do this: from itertools import permutations def build_hand(self): for hand in permutations(self.deck): self.hand.append(hand) self.build_hand() self.hand = [c for c in self.hand] self.score = 0 You'll need to do some work if you want to give a specific number of cards to each hand. For instance, to make a hand of 2 and a hand of 5: from itertools import combinations, permutations def build_hand(self): for hand in combinations(range(2), 2): for hand in permutations(range(5)): self.hand.append(hand) self.build_hand() self.hand = [c for c in self.hand] self.hand = [c for c in self.hand] self.score = 0 254 F.Supp. 659 (1966) The FIRST NATIONAL BANK OF IOWA