fork(1) download
  1. from itertools import product
  2. from collections import Counter
  3.  
  4. cards = Counter()
  5. hand = Counter()
  6.  
  7. for x in product({x for x in range(1,7)}, repeat=5):
  8. p = tuple(sorted(x))
  9. cards[p] += 1
  10.  
  11. for k,v in cards.items():
  12. analysis = Counter(k)
  13. values = analysis.values()
  14. if 5 in values: hand["five_of_a_kind"] += v
  15. elif 4 in values: hand["four_of_a_kind"] += v
  16. elif 3 in values:
  17. if 2 in values:
  18. hand["full_house"] += v
  19. else:
  20. hand["three_of_a_kind"] += v
  21. elif 2 in values:
  22. if len(values) == 3:
  23. hand["two_pair"] += v
  24. else:
  25. hand["one_pair"] += v
  26. elif k[-1] - k[0] == 4:
  27. hand["straight"] += v
  28. else:
  29. hand["nothing"] += v
  30.  
  31. for x in ("five_of_a_kind","four_of_a_kind","full_house","straight","three_of_a_kind","two_pair","one_pair","nothing"):
  32. print("{} :\n {} / 7776 ({} %)".format(x,hand[x], round(100*hand[x]/7776,2)))
Success #stdin #stdout 0.02s 27616KB
stdin
Standard input is empty
stdout
five_of_a_kind :
 6 / 7776 (0.08 %)
four_of_a_kind :
 150 / 7776 (1.93 %)
full_house :
 300 / 7776 (3.86 %)
straight :
 240 / 7776 (3.09 %)
three_of_a_kind :
 1200 / 7776 (15.43 %)
two_pair :
 1800 / 7776 (23.15 %)
one_pair :
 3600 / 7776 (46.3 %)
nothing :
 480 / 7776 (6.17 %)