From b52f5785041f63b7e2726dae8aef9126d009d9e1 Mon Sep 17 00:00:00 2001 From: mollychi Date: Sun, 9 Nov 2025 20:10:19 -0500 Subject: [PATCH] I knew I had to see how many of the dice were the same but I unsure how to do it so i did some research on the internet to help me solve this one. A problem you could solve with classes in coding could be a algebara problem that requires multiple steps. I have trouble thinking of real life situtations --- dice_stats.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dice_stats.py b/dice_stats.py index 83a99cb..7e64086 100644 --- a/dice_stats.py +++ b/dice_stats.py @@ -1,5 +1,6 @@ from die import Die from tqdm import tqdm +from collections import Counter class FiveDice: def __init__(self): @@ -18,6 +19,22 @@ class FiveDice: if face != 1: return False return True + + def is_three_of_a_kind(self): + counts = Counter(self.dice) + for count in counts.value(): + if count >= 3: + return True + return False + + def is_four_of_a_kind(self): + counts = Counter(self.dice) + for count in counts.value(): + if count >= 4: + return True + return False + + dice = FiveDice() successes = 0