def get_all_winning_hands()

in evals/elsuite/bluff/bluff/cards.py [0:0]


def get_all_winning_hands(*in_cards: PlayerCards):
    """Return all winning poker hands for a given set of cards, sorted from weakest to strongest.

    NOTE: this is equivalent to
        [hand for hand in get_all_hands() if hand.evaluate(*cards)]
    but much faster.
    """
    all_cards = []
    for cards in in_cards:
        all_cards += cards.no_suit()

    winning_hands = []
    winning_hands += [HighCard(card) for card in set(all_cards)]
    winning_hands += [OnePair(card) for card in set(all_cards) if all_cards.count(card) >= 2]
    winning_hands += [ThreeOfAKind(card) for card in set(all_cards) if all_cards.count(card) >= 3]
    winning_hands += [FourOfAKind(card) for card in set(all_cards) if all_cards.count(card) >= 4]

    pairs = [x for x in winning_hands if isinstance(x, OnePair)]
    for ix, first_pair in enumerate(pairs):
        for second_pair in pairs[ix + 1 :]:
            winning_hands.append(TwoPair(first_pair.card, second_pair.card))

    trios = [x for x in winning_hands if isinstance(x, ThreeOfAKind)]
    for trio in trios:
        for pair in pairs:
            if trio.card != pair.card:
                winning_hands.append(FullHouse(trio.card, pair.card))

    winning_hands.sort()

    return winning_hands