From 0b73c18a72a642c5f254a1a09078260916a740eb Mon Sep 17 00:00:00 2001 From: hikarikumo Date: Sun, 17 Dec 2023 19:12:17 +0200 Subject: [PATCH] trying to reduce cognitive complexity for prime_game Signed-off-by: hikarikumo --- brain_games/prime_game.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/brain_games/prime_game.py b/brain_games/prime_game.py index 7cf484e..ed11fd2 100644 --- a/brain_games/prime_game.py +++ b/brain_games/prime_game.py @@ -3,13 +3,6 @@ from cli import greet_first, welcome_user -def question_prime(): - """Ask the question and return a tuple (number_to_guess, user_answer).""" - number_to_guess = random.randint(1, 100) - user_answer = prompt.string(f'Number: {number_to_guess}\n') - return number_to_guess, user_answer - - def prime_goal(): """Provide information about the goal of the prime game to the user.""" print('Answer "yes" if given number is prime. Otherwise answer "no".\n') @@ -24,7 +17,8 @@ def is_prime(number): def prime_game(name): """Brain game prime logic.""" for _ in range(3): - random_number, user_answer = question_prime() + random_number = random.randint(1, 100) + user_answer = prompt.string(f'Number: {random_number}\n') prime_status = is_prime(random_number) expected_answer = 'yes' if prime_status else 'no'