From 5c6e22c6031b871673881c8745a159a8b55e099c Mon Sep 17 00:00:00 2001 From: Xueyan Zhang Date: Fri, 15 May 2026 00:16:17 -0400 Subject: [PATCH 1/7] Fix consecutive-wins bug in solution - remove uninitialized `runner.consecutive_wins` attribute - roll the dice each round --- solutions/dicegame/runner.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 7456360..d7c3085 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -1,4 +1,4 @@ -from .die import Die +from .die import Die, roll from .utils import i_just_throw_an_exception class GameRunner: @@ -21,12 +21,14 @@ def answer(self): @classmethod def run(cls): - count = 0 + consecutive_wins = 0 runner = cls() while True: print("Round {}\n".format(runner.round)) + roll(runner.dice) + for die in runner.dice: print(die.show()) @@ -36,18 +38,17 @@ def run(cls): if guess == runner.answer: print("Congrats, you can add like a 5 year old...") runner.wins += 1 - count += 1 - runner.consecutive_wins += 1 + consecutive_wins += 1 else: print("Sorry that's wrong") print("The answer is: {}".format(runner.answer)) print("Like seriously, how could you mess that up") runner.loses += 1 - count = 0 + consecutive_wins = 0 print("Wins: {} Loses {}".format(runner.wins, runner.loses)) runner.round += 1 - if count == 6: + if consecutive_wins == 6: print("You won... Congrats...") print("The fact it took you so long is pretty sad") break From 9acb89f897be75dcbb09891424534615199d4123 Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:12 +0800 Subject: [PATCH 2/7] Update solutions/dicegame/runner.py as per suggestion from @@rogerlucena Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index d7c3085..445bd26 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -21,7 +21,6 @@ def answer(self): @classmethod def run(cls): - consecutive_wins = 0 runner = cls() while True: From 4c9290f1a30a8e7119dd3fd9602388fc4b83858b Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:20 +0800 Subject: [PATCH 3/7] Update solutions/dicegame/runner.py Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 445bd26..6376890 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -27,7 +27,6 @@ def run(cls): print("Round {}\n".format(runner.round)) roll(runner.dice) - for die in runner.dice: print(die.show()) From a75617eab0300f64b5d9f49448580eb1bcae5e4f Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:28 +0800 Subject: [PATCH 4/7] Update solutions/dicegame/runner.py Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 6376890..9e288eb 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -11,6 +11,7 @@ def reset(self): self.round = 1 self.wins = 0 self.loses = 0 + self.consecutive_wins = 0 @property def answer(self): From d99b466e0fd79b723a046ab450df16f5f7c0c34e Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:35 +0800 Subject: [PATCH 5/7] Update solutions/dicegame/runner.py Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 9e288eb..60193e0 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -37,7 +37,7 @@ def run(cls): if guess == runner.answer: print("Congrats, you can add like a 5 year old...") runner.wins += 1 - consecutive_wins += 1 + runner.consecutive_wins += 1 else: print("Sorry that's wrong") print("The answer is: {}".format(runner.answer)) From c397871368d4bc03d55be242fb6fbe049f6ce72c Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:45 +0800 Subject: [PATCH 6/7] Update solutions/dicegame/runner.py Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 60193e0..22c8249 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -43,7 +43,7 @@ def run(cls): print("The answer is: {}".format(runner.answer)) print("Like seriously, how could you mess that up") runner.loses += 1 - consecutive_wins = 0 + runner.consecutive_wins = 0 print("Wins: {} Loses {}".format(runner.wins, runner.loses)) runner.round += 1 From 67fb6c9f2cd4ac83d29068e04f3744b4c8b52d45 Mon Sep 17 00:00:00 2001 From: XUEYANZ Date: Sat, 29 Aug 2026 15:29:52 +0800 Subject: [PATCH 7/7] Update solutions/dicegame/runner.py Co-authored-by: Roger Leite Lucena <27161330+rogerlucena@users.noreply.github.com> --- solutions/dicegame/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/dicegame/runner.py b/solutions/dicegame/runner.py index 22c8249..d362dd3 100644 --- a/solutions/dicegame/runner.py +++ b/solutions/dicegame/runner.py @@ -47,7 +47,7 @@ def run(cls): print("Wins: {} Loses {}".format(runner.wins, runner.loses)) runner.round += 1 - if consecutive_wins == 6: + if runner.consecutive_wins == 6: print("You won... Congrats...") print("The fact it took you so long is pretty sad") break