Ask Your Question

Revision history [back]

Using what you have so far:

Suits = Set(["Hearts", "Diamonds", "Spades", "Clubs"])
Values = Set([2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"])
X = Arrangements(Values, 2)  # two values: first will be the singleton, second will be 4 of a kind

Now we can construct the hands in several ways. Using a loop:

Hands = []
for a in X:
    for s in Suits:
        first_card = (a[0], s)
        rest = [(a[1], Suits[i]) for i in range(4)]
        hand = [first_card] + rest
        Hands.append(hand)

Or more briefly using list comprehension:

Hands = [[(a[0], s)] + [(a[1], Suits[i]) for i in range(4)] for a in X for s in Suits]