Skip to content

Commit

Permalink
update 'progression.py', 'brain_progression.py'
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVangeli committed Sep 28, 2024
1 parent 86ca68e commit ed9b180
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Binary file modified brain_games/games/__pycache__/progression.cpython-310.pyc
Binary file not shown.
21 changes: 10 additions & 11 deletions brain_games/games/progression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
from brain_games.utils import get_random_number


def start_progression_game():
play_game(run_progression_round, PROGRESSION_RULES)


def run_progression_round(username: str) -> bool:
def get_progression_and_missed_number(username: str) -> bool:
"""
Генерирует арифметическую прогрессию и скрывает один из ее элементов.
Expand All @@ -18,14 +14,17 @@ def run_progression_round(username: str) -> bool:
start = get_random_number(1, 100)
step = get_random_number(1, 40)
length = get_random_number(5, 10)

progression_list = [start + step * i for i in range(length)]

hide_index = get_random_number(0, length - 1)
correct_answer = str(progression_list[hide_index])

question = " ".join(
".." if i == hide_index else str(num)
for i, num in enumerate(progression_list)
".." if i == hide_index else str(start + i * step)
for i in range(length)
)

correct_answer = str(start + hide_index * step)

return ask_question(question, correct_answer, username)


def run_progression_game():
play_game(get_progression_and_missed_number, PROGRESSION_RULES)
Binary file not shown.
4 changes: 2 additions & 2 deletions brain_games/scripts/brain_progression.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from brain_games.games.progression import start_progression_game
from brain_games.games.progression import run_progression_game


def main():
start_progression_game()
run_progression_game()


if __name__ == "__main__":
Expand Down

0 comments on commit ed9b180

Please sign in to comment.