Skip to content

Commit

Permalink
trying to reduce cognitive complexity for prime_game
Browse files Browse the repository at this point in the history
Signed-off-by: hikarikumo <[email protected]>
  • Loading branch information
hikarikumo committed Dec 17, 2023
1 parent 2026036 commit 0b73c18
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions brain_games/prime_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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'
Expand Down

0 comments on commit 0b73c18

Please sign in to comment.