Skip to content

Commit 7ac5fdc

Browse files
committed
all changes 8-th step of project
1 parent af49118 commit 7ac5fdc

12 files changed

+147
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ brain-even: https://asciinema.org/a/5JkOomCYitwZ5YMmXGrbKf7vO
88
brain-calc: https://asciinema.org/a/daDnWV3XC3pNoNAFgOneXFrU7
99

1010
brain-gdc: https://asciinema.org/a/o4wK1dzQaefQiUzAt2QBRbVBQ
11+
12+
brain-progression: https://asciinema.org/a/sKFhvVykjbhLLwAzoAsbudPlz
Binary file not shown.
1003 Bytes
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import brain_games.scripts.games.sample
2+
3+
4+
def game_progression():
5+
cond_answer = 'What number is missing in the progression?'
6+
return brain_games.scripts.games.sample.samples('brain-progression', cond_answer)
7+
8+
9+
def main():
10+
print('Welcome to the Brain Games!')
11+
print(game_progression())
12+
13+
14+
if __name__ == '__main__':
15+
main()

brain_games/scripts/games/sample.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ def type_brain_gcd(frs_num, sec_num):
3333
return max(re)
3434

3535

36+
def typo_brain_progression(first_num):
37+
re = []
38+
range_progressing = random.randint(5, 10)
39+
sec_num = random.randint(1, 5)
40+
for _ in range(range_progressing):
41+
re.append(str(first_num))
42+
first_num += sec_num
43+
index_replace_num = re.index(random.choice(re[1:]))
44+
replace_num = re[index_replace_num - 1]
45+
re.insert(index_replace_num, '..')
46+
re.remove(re[index_replace_num - 1])
47+
progressing_str = ' '.join(re)
48+
print(f'Question: {progressing_str}')
49+
return replace_num
50+
51+
3652
def samples(type_game, condition_answer):
3753
name = prompt.string('May I have your name? ')
3854
number_of_successful_attempts = 0
@@ -46,8 +62,10 @@ def samples(type_game, condition_answer):
4662
first_number = random.randint(1, 25)
4763
second_number = random.randint(1, 25)
4864
correct_answer = type_brain_calc(first_number, second_number)
49-
else:
65+
elif type_game == 'brain-gcd':
5066
correct_answer = type_brain_gcd(first_number, second_number)
67+
else:
68+
correct_answer = typo_brain_progression(first_number)
5169
answer = input('Your answer: ')
5270
if answer == str(correct_answer):
5371
number_of_successful_attempts += 1
-4.46 KB
Binary file not shown.

dist/hexlet_code-0.1.0.tar.gz

-5.22 KB
Binary file not shown.
5.07 KB
Binary file not shown.

dist/hexlet_code-0.4.0.tar.gz

6.19 KB
Binary file not shown.

gcd.cast

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{"version": 2, "width": 80, "height": 24, "timestamp": 1732214428, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2+
[0.027871, "o", "\u001b[?2004h\u001b]0;ttehasi@ttehasi-MEGABOOK-T15DA: ~/python-project-49\u0007\u001b[01;32mttehasi@ttehasi-MEGABOOK-T15DA\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
3+
[3.00516, "o", "b"]
4+
[3.138265, "o", "r"]
5+
[3.481145, "o", "a"]
6+
[3.70558, "o", "i"]
7+
[4.057468, "o", "n"]
8+
[5.781337, "o", "-"]
9+
[7.084494, "o", "g"]
10+
[7.207131, "o", "\u0007"]
11+
[7.943458, "o", "c"]
12+
[8.031703, "o", "d "]
13+
[8.68439, "o", "\r\n\u001b[?2004l\r"]
14+
[8.715629, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
15+
[10.998735, "o", "b"]
16+
[11.077515, "o", "i"]
17+
[11.261286, "o", "l"]
18+
[11.345713, "o", "l"]
19+
[12.081259, "o", "\r\n"]
20+
[12.081357, "o", "Find the greatest common divisor of given numbers.\r\nQuestion: 35 14\r\n"]
21+
[12.081818, "o", "Your answer: "]
22+
[14.347456, "o", "2"]
23+
[15.202515, "o", "\b \b"]
24+
[15.360013, "o", "1"]
25+
[16.29974, "o", "\r\n"]
26+
[16.299841, "o", "'1' is wrong answer ;(. Correct answer was '7'\r\nLet's try again, bill!\r\n"]
27+
[16.308293, "o", "\u001b[?2004h\u001b]0;ttehasi@ttehasi-MEGABOOK-T15DA: ~/python-project-49\u0007\u001b[01;32mttehasi@ttehasi-MEGABOOK-T15DA\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
28+
[19.03441, "o", "brain-gcd "]
29+
[20.423636, "o", "\r\n\u001b[?2004l\r"]
30+
[20.453788, "o", "Welcome to the Brain Games!\r\nMay I have your name? "]
31+
[22.27755, "o", "v"]
32+
[22.764595, "o", "i"]
33+
[23.21673, "o", "l"]
34+
[23.614216, "o", "l"]
35+
[24.379289, "o", "\r\n"]
36+
[24.379599, "o", "Find the greatest common divisor of given numbers.\r\n"]
37+
[24.379671, "o", "Question: 5 6\r\nYour answer: "]
38+
[26.948055, "o", "1"]
39+
[27.817158, "o", "\r\n"]
40+
[27.81723, "o", "Correct!\r\n"]
41+
[27.817522, "o", "Question: 34 31\r\nYour answer: "]
42+
[31.589086, "o", "1"]
43+
[31.861453, "o", "\r\n"]
44+
[31.861698, "o", "Correct!\r\n"]
45+
[31.861827, "o", "Question: 5 16\r\nYour answer: "]
46+
[35.369029, "o", "1"]
47+
[35.648064, "o", "\r\n"]
48+
[35.648255, "o", "Correct!\r\nCongratulations, vill!\r\n"]
49+
[35.656358, "o", "\u001b[?2004h\u001b]0;ttehasi@ttehasi-MEGABOOK-T15DA: ~/python-project-49\u0007\u001b[01;32mttehasi@ttehasi-MEGABOOK-T15DA\u001b[00m:\u001b[01;34m~/python-project-49\u001b[00m$ "]
50+
[40.054627, "o", "e"]
51+
[40.283406, "o", "x"]
52+
[40.610461, "o", "i"]
53+
[40.873663, "o", "t"]
54+
[41.495615, "o", "\r\n\u001b[?2004l\r"]
55+
[41.495714, "o", "exit\r\n"]

0 commit comments

Comments
 (0)