From bacad32a618bc6b87c354b0e4757b3c74ad42eb7 Mon Sep 17 00:00:00 2001 From: Joe Nellis Date: Sun, 24 Apr 2022 17:39:03 -0700 Subject: [PATCH] Off by one error in for/range. Previously if the computer chose a secret code of zero (all blacks) it would skip initialization entirely and the player would not be able to finish the puzzle. Alternatively, if the computer chose the highest secret code (e.g. all Red in a three color puzzle), the actual secret code would be initialized to one less (RRW). --- 60_Mastermind/python/mastermind.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/60_Mastermind/python/mastermind.py b/60_Mastermind/python/mastermind.py index b37477fb..4c53439a 100644 --- a/60_Mastermind/python/mastermind.py +++ b/60_Mastermind/python/mastermind.py @@ -46,7 +46,7 @@ def main() -> None: print("Guess my combination ...") answer = int(possibilities * random.random()) numeric_answer = [-1] * num_positions - for _ in range(0, answer): + for _ in range(0, answer + 1): numeric_answer = get_possibility(numeric_answer) # human_readable_answer = make_human_readable(numeric_answer, color_letters) while num_moves < 10 and not turn_over: