generated from mwc/lab_dice
The math and or numbers were easy for me to work with
This commit is contained in:
@@ -19,12 +19,24 @@ class FiveDice:
|
||||
return False
|
||||
return True
|
||||
|
||||
def is_three_of_a_kind(self):
|
||||
for face in self.faces():
|
||||
if face != 3:
|
||||
return False
|
||||
return True
|
||||
|
||||
def is_four_of_a_kind(self):
|
||||
for face in self.faces():
|
||||
if face != 4:
|
||||
return False
|
||||
return True
|
||||
|
||||
dice = FiveDice()
|
||||
successes = 0
|
||||
trials = 1000000
|
||||
for trial in tqdm(range(trials)):
|
||||
dice.roll()
|
||||
if dice.all_ones():
|
||||
if dice.is_four_of_a_kind():
|
||||
successes += 1
|
||||
|
||||
print(successes/trials)
|
||||
|
||||
Reference in New Issue
Block a user