From 800b6671c3b567b30cbf92f99c541722363f7b86 Mon Sep 17 00:00:00 2001 From: juddin2 Date: Sun, 9 Nov 2025 19:32:03 -0500 Subject: [PATCH] I wrote 2 new functions. I could use classes to stimulate a deck of cards. --- dice_stats.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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():