diff --git a/dice_stats.py b/dice_stats.py index 83a99cb..857e02a 100644 --- a/dice_stats.py +++ b/dice_stats.py @@ -18,10 +18,24 @@ class FiveDice: if face != 1: return False return True + def is_three_of_a_kind(self): + faces = self.faces() + for face in faces: + count = faces.count(face) + if count >= 3: + return True + return False -dice = FiveDice() + def is_four_of_a_kind(self): + faces = self.faces() + for face in faces: + count = faces.count(face) + if count >= 4: + return True + return False successes = 0 trials = 1000000 +dice= FiveDice() for trial in tqdm(range(trials)): dice.roll() if dice.all_ones():