From 44983bb25fc9c121753005553581494aae16ee81 Mon Sep 17 00:00:00 2001 From: Joe Nellis Date: Fri, 29 Apr 2022 13:54:53 -0700 Subject: [PATCH] More off by 1 errors of the same type as the previous commit for the computer guessing the secret code. All errors are involved in the algortihm that converts an empty list to a guess. --- 60_Mastermind/python/mastermind.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/60_Mastermind/python/mastermind.py b/60_Mastermind/python/mastermind.py index 4c53439a..843466ea 100644 --- a/60_Mastermind/python/mastermind.py +++ b/60_Mastermind/python/mastermind.py @@ -132,7 +132,7 @@ def main() -> None: inconsistent_information = True else: numeric_guess = [-1] * num_positions - for _ in range(0, guess): + for _ in range(0, guess+1): numeric_guess = get_possibility(numeric_guess) human_readable_guess = make_human_readable( numeric_guess, color_letters @@ -154,7 +154,7 @@ def main() -> None: if all_possibilities[i] == 0: # already ruled out continue numeric_possibility = [-1] * num_positions - for _ in range(0, i): + for _ in range(0, i+1): numeric_possibility = get_possibility( numeric_possibility )