Skip to content

Commit

Permalink
prime game reducing complexity
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 7ab5991 commit de5821e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions brain_games/prime_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ def prime_goal():


def is_prime(number):
"""Check if the number is prime."""
divisors = [count for count in range(1, number + 1) if number % count == 0]
return len(divisors) == 2


def prime_game(name):
"""Brain game prime logic."""
for _ in range(3):
random_number, user_answer = question_prime()
prime_status = is_prime(random_number)
Expand All @@ -35,9 +33,10 @@ def prime_game(name):
if _ == 2:
print(f'Congratulations, {name}!')
return True
else:
print(f"Let's try again, {name}!")
return False

print(f"Let's try again, {name}!")

return False


def main():
Expand Down

0 comments on commit de5821e

Please sign in to comment.