From 80535dd9866cfba892c8db7249bcab14d88ce572 Mon Sep 17 00:00:00 2001 From: louiscooper136 Date: Mon, 5 Feb 2024 20:20:45 -0500 Subject: [PATCH] Completed Checkpoint 1. 1) I think making a game, you could simulate a character class in an RPG! Hair color, wieght, special abilities, each character would be a different object in the character class. --- __pycache__/die.cpython-310.pyc | Bin 0 -> 726 bytes dice_stats.py | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 __pycache__/die.cpython-310.pyc diff --git a/__pycache__/die.cpython-310.pyc b/__pycache__/die.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbfa34d58379183cadaa47ac28ec978e89202a96 GIT binary patch literal 726 zcmZ`%y^hpC47O*I-LPbZbS)AUO`3}k6%s-xfkd~>cH3AXp5p@fIVM@1SY5aGAY8c* z!HWzf)xH81b|TP99G2`Ej~#!X?R3lK0z`g%5BwAXeyVdSR-6mb{+SpC#u^&jAi{fK z!}bo??#;$GBxl4i&*Y4G zE;W;2-&L*@YJWxVTIj84pNhGKZ*UJN^ww~|l@N%0SJwwQdskl`z$cRR>s5Z$H7+l^ z?%Me}Z;H=V`;l&{;fl(RUEbW3FY;|$4KMS$_&{8hF6YXfUw;h=Q6&MQM~bQ7Deh7s zcK#>ue}+2WK{$TGJ+8q=;$|k;e()i>EK28R@-i}*-WR= z7L6kc3!;k8Gvl-29iB#>ZYQ#-z{G8<<44|UDN UR8t?S5t7#v{u^y>q8p!?--QK-)c^nh literal 0 HcmV?d00001 diff --git a/dice_stats.py b/dice_stats.py index 83a99cb..aee761d 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,21 @@ class FiveDice: if face != 1: return False return True + + + def is_three_of_a_kind(self): + count = Counter(self.faces()) + for face_count in count.values(): + if face_count == 3: + return True + return False + + def is_four_of_a_kind(self): + count = Counter(self.faces()) + for face_count in count.values(): + if face_count == 4: + return True + return False dice = FiveDice() successes = 0 @@ -28,6 +44,9 @@ for trial in tqdm(range(trials)): successes += 1 print(successes/trials) - +#print(f"dice rolls: {dice.faces()}") +print(dice.faces()) +print(dice.is_three_of_a_kind()) +print(dice.is_four_of_a_kind())