Skip to content

Commit

Permalink
update 'gcd.py'
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVangeli committed Oct 3, 2024
1 parent 64dfe30 commit 4ec9181
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions brain_games/games/gcd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math

from brain_games.const import GCD_RULES
from brain_games.games.engine import ask_question, play_game
from brain_games.games.engine import play_game
from brain_games.utils import get_random_number


Expand All @@ -23,7 +23,7 @@ def find_gcd(a: int, b: int) -> int:
return math.gcd(a, b)


def run_gcd_round(username: str) -> bool:
def run_gcd_round() -> tuple[str, str]:
"""
Проводит один раунд игры на нахождение НОД двух случайных чисел.
Expand All @@ -37,15 +37,16 @@ def run_gcd_round(username: str) -> bool:
username (str): Имя пользователя
Returns:
bool: True, если игрок дал правильный ответ, False в случае ошибки.
tuple[str, str]: Кортеж, содержащий вопрос в виде строки и правильный
ответ в виде строки.
"""
number_one, number_two = get_random_number(), get_random_number()
if (
number_one == 1
or number_two == 1
or find_gcd(number_one, number_two) == 1
):
return run_gcd_round(username)
return run_gcd_round()
question = f"{number_one} {number_two}"
correct_answer = str(find_gcd(number_one, number_two))
return ask_question(question, correct_answer, username)
return question, correct_answer

0 comments on commit 4ec9181

Please sign in to comment.