Skip to content

Commit 8328670

Browse files
committed
Add progression.py, brain_progression.py
1 parent 2dc8e2b commit 8328670

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

brain_games/games/progression.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from brain_games.engine import run_game
2+
from brain_games.utils import get_random_num, get_random_length_and_index
3+
from brain_games.consts import PROGRESSION_INSTRUCTION
4+
5+
6+
def get_progression_and_answer():
7+
length, index = get_random_length_and_index()
8+
step = get_random_num()
9+
start = get_random_num()
10+
11+
progression = ''
12+
13+
for i in range(length):
14+
if index == i:
15+
answer = str(start + i * step)
16+
progres_element = '..'
17+
else:
18+
progres_element = str(start + i * step)
19+
progression = progression + ' ' + progres_element
20+
21+
return progression, answer
22+
23+
24+
def run_progression_game():
25+
run_game(get_progression_and_answer, PROGRESSION_INSTRUCTION)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from brain_games.games.progression import run_progression_game
2+
3+
4+
def main():
5+
run_progression_game()
6+
7+
8+
if __name__ == "__main__":
9+
main()

0 commit comments

Comments
 (0)