Skip to content

Commit ce50577

Browse files
touch brain_progression and progression.py
1 parent bdbd7ae commit ce50577

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ The first project on [Hexlet](https://ru.hexlet.io/professions/python/projects/4
1616
### THE THIRD GAME: brain-gcd
1717

1818
[![asciicast](https://asciinema.org/a/vXRRiDnzBx0r5Q6xjE9iSBHZf.svg)](https://asciinema.org/a/vXRRiDnzBx0r5Q6xjE9iSBHZf)
19+
20+
### THE FOURTH GAME: brain-progression
21+
22+
[![asciicast](https://asciinema.org/a/kSeWIg1XFAvI37egtMgaKHNqK.svg)](https://asciinema.org/a/kSeWIg1XFAvI37egtMgaKHNqK)
23+

brain_games/games/progression.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from random import choice, randint
2+
3+
RULES = 'What number is missing in the progression?'
4+
5+
6+
def start_game():
7+
step = randint(1, 11)
8+
rang = randint(12, 16)
9+
10+
progression = []
11+
12+
for i in range(2, rang):
13+
num = step * i
14+
progression.append(str(num))
15+
16+
answer = choice(progression)
17+
question = ' '.join(progression)
18+
question = question.replace(answer, '..', 1)
19+
return (question, answer)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from brain_games.game_skeleton import game_start
2+
from brain_games.games import progression
3+
4+
5+
def main():
6+
game_start(progression)
7+
8+
9+
if __name__ == "__main__":
10+
main()

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ 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"
2727
brain-gcd = "brain_games.scripts.brain_gcd:main"
28+
brain-progression = "brain_games.scripts.brain_progression:main"

0 commit comments

Comments
 (0)