Skip to content

Instantly share code, notes, and snippets.

@hclivess
Created June 25, 2022 20:47
Show Gist options
  • Save hclivess/b1d7a780412c0b5d88412d87bf73d77d to your computer and use it in GitHub Desktop.
Save hclivess/b1d7a780412c0b5d88412d87bf73d77d to your computer and use it in GitHub Desktop.
dice_probability.py
import random
a = [3, 3, 3, 3, 3, 3]
b = [6, 5, 2, 2, 2, 2]
c = [4, 4, 4, 4, 1, 1]
a_wins = 0
b_wins = 0
c_wins = 0
for _ in range(0, 100000):
a_roll = random.choice(a)
b_roll = random.choice(b)
c_roll = random.choice(c)
lst = {"a_roll": a_roll, "b_roll": b_roll, "c_roll": c_roll}
winner = (max(lst, key=lst.get))
print(winner)
if winner == "a_roll":
a_wins += 1
if winner == "b_roll":
b_wins += 1
if winner == "c_roll":
c_wins += 1
print("a_wins", a_wins)
print("b_wins", b_wins)
print("c_wins", c_wins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment