Created
January 24, 2023 04:27
-
-
Save matteodelabre/e35f9e97467ec53cad6f7395f55cbf37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from itertools import product | |
from collections import Counter | |
suits = ["♡", "♣", "♢", "♠"] | |
values = ["5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] | |
def deal(): | |
hands = list(product(suits, values)) | |
random.shuffle(hands) | |
return [hands[i:i+10] for i in range(0, 40, 10)] | |
def stats(hands): | |
hand_counts = [Counter(card[0] for card in hand) for hand in hands] | |
return [ | |
tuple(sorted(compo[suit] for compo in hand_counts)[::-1]) | |
for suit in suits | |
] | |
random.seed(42) | |
repeats = 1_000_000 | |
counts = Counter() | |
for _ in range(repeats): | |
hands = deal() | |
for config in stats(hands): | |
counts[config] += 1 | |
for conf, count in counts.most_common(): | |
print(f"{conf} {100 * count / (4 * repeats):.2f}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment