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
This commit is contained in:
mollychi
2025-11-09 20:10:19 -05:00
parent 131c9b1070
commit b52f578504

View File

@@ -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