Skip to content

Commit 6bc4876

Browse files
committed
Добавлена новая игра Арифметическая прогрессия
1 parent 69fc898 commit 6bc4876

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ brain-calc:
1919
brain-gcd:
2020
uv run brain-gcd
2121

22+
brain-progresssion:
23+
uv run brain-progression
24+
2225
lint:
2326
uv run ruff check brain_games

brain_games/games/progression.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import random
2+
rules = 'What number is missing in the progression?'
3+
def get_round():
4+
start = random.randint(1, 50)
5+
step = random.randint(1, 10)
6+
lenght = random.randint(5, 11)
7+
progression = []
8+
progression = list(range(start, start+step*lenght, step))
9+
hiden_index = random.randint(0, lenght - 1)
10+
correct_answer = str(progression[hiden_index])
11+
progression[hiden_index] = '..'
12+
progression_str = ' '.join(map(str, progression))
13+
question = f'Question: {progression_str}'
14+
return question, correct_answer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
from brain_games.engine import run_game
3+
from brain_games.games import progression
4+
def main():
5+
run_game(progression)
6+
7+
if __name__ == '__main__':
8+
main()

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "hexlet-code"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -24,4 +24,5 @@ dev = [
2424
brain-games = "brain_games.scripts.brain_games:main"
2525
brain-even = "brain_games.scripts.brain_even:main"
2626
brain-calc = "brain_games.scripts.brain_calc:main"
27-
brain-gcd = "brain_games.scripts.brain_gcd:main"
27+
brain-gcd = "brain_games.scripts.brain_gcd:main"
28+
brain-progression = "brain_games.scripts.brain_progression:main"

0 commit comments

Comments
 (0)