Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ install:
brain-games:
uv run brain-games

brain-calc:
uv run brain-calc

build:
uv build

Expand Down
Binary file modified brain_games/__pycache__/cli.cpython-313.pyc
Binary file not shown.
Binary file modified brain_games/__pycache__/wrong_answer_output.cpython-313.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion brain_games/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
def welcome_user():
print('Welcome to the Brain Games!')
name = prompt.string('May I have your name? ')
print(f'Hello, {name}!\n')
print(f'Hello, {name}!')

return name
1 change: 1 addition & 0 deletions brain_games/scripts/games/__init_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file modified brain_games/scripts/games/__pycache__/brain_calc.cpython-313.pyc
Binary file not shown.
Binary file modified brain_games/scripts/games/__pycache__/brain_even.cpython-313.pyc
Binary file not shown.
Binary file modified brain_games/scripts/games/__pycache__/brain_games.cpython-313.pyc
Binary file not shown.
Binary file modified brain_games/scripts/games/__pycache__/brain_gcd.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 1 addition & 7 deletions brain_games/scripts/games/brain_calc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import operator
from random import choice, randint
from time import sleep

from prompt import string

Expand All @@ -16,9 +15,7 @@ def calc_game(name):
"*": operator.mul,
}

sleep(1)
print('What is the result of the expression?')
sleep(1)

correct_guesses = 0

Expand All @@ -33,12 +30,9 @@ def calc_game(name):
if answer != correct_answer:
wrong_answer_output(answer, correct_answer, name)

sleep(2)

continue
return

print('Correct!\n')
sleep(1)

correct_guesses += 1

Expand Down
18 changes: 5 additions & 13 deletions brain_games/scripts/games/brain_even.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from random import randint
from time import sleep

from prompt import string

Expand All @@ -8,10 +7,8 @@


def is_even_game(name):
sleep(1)
print('Answer "yes" if the number is even, otherwise answer "no".\n')
sleep(1)

print('Answer "yes" if the number is even, otherwise answer "no".')

correct_guesses = 0

while correct_guesses < 3:
Expand All @@ -23,18 +20,13 @@ def is_even_game(name):
if answer != correct_answer:
wrong_answer_output(answer, correct_answer, name)

sleep(2)

correct_guesses = 0

continue
return

print('Correct!\n')
sleep(1)
print('Correct!')

correct_guesses += 1

print(f'Congratulations, {name}!\n')
print(f'Congratulations, {name}!')

return

Expand Down
13 changes: 1 addition & 12 deletions brain_games/scripts/games/brain_games.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
from brain_games.cli import welcome_user
from brain_games.scripts.games.brain_calc import calc_game
from brain_games.scripts.games.brain_even import is_even_game
from brain_games.scripts.games.brain_gcd import gcd_game
from brain_games.scripts.games.brain_progression import progression_game
from brain_games.scripts.games.brain_prime import is_prime_game


def main():
name = welcome_user()
is_even_game(name)
calc_game(name)
gcd_game(name)
progression_game(name)
is_prime_game(name)

welcome_user()


if __name__ == "__main__":
Expand Down
8 changes: 1 addition & 7 deletions brain_games/scripts/games/brain_gcd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from random import randint
from time import sleep

from prompt import string

Expand All @@ -16,9 +15,7 @@ def get_gcd(a, b):


def gcd_game(name):
sleep(1)
print('Find the greatest common divisor of given numbers.\n')
sleep(1)

correct_guesses = 0

Expand All @@ -37,12 +34,9 @@ def gcd_game(name):
if answer != correct_answer:
wrong_answer_output(answer, correct_answer, name)

sleep(2)

continue
return

print('Correct!\n')
sleep(1)

correct_guesses += 1

Expand Down
8 changes: 1 addition & 7 deletions brain_games/scripts/games/brain_prime.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from random import choice, randint
from time import sleep

from prompt import string

Expand Down Expand Up @@ -28,9 +27,7 @@ def prime_generator(num):


def is_prime_game(name):
sleep(1)
print('Answer "yes" if given number is prime. Otherwise answer "no".\n')
sleep(1)

correct_guesses = 0

Expand All @@ -46,12 +43,9 @@ def is_prime_game(name):
if answer != correct_answer:
wrong_answer_output(answer, correct_answer, name)

sleep(2)

continue
return

print('Correct!\n')
sleep(1)

correct_guesses += 1

Expand Down
8 changes: 1 addition & 7 deletions brain_games/scripts/games/brain_progression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from random import randint
from time import sleep

from prompt import string

Expand All @@ -8,9 +7,7 @@


def progression_game(name):
sleep(1)
print('What number is missing in the progression?\n')
sleep(1)

correct_guesses = 0

Expand All @@ -29,12 +26,9 @@ def progression_game(name):
if answer != correct_answer:
wrong_answer_output(answer, correct_answer, name)

sleep(2)

continue
return

print('Correct!\n')
sleep(1)

correct_guesses += 1

Expand Down
2 changes: 1 addition & 1 deletion brain_games/wrong_answer_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def wrong_answer_output(answer, correct_answer, name):
print(
f"'{answer}' is wrong answer ;(. "
f"Correct answer was '{correct_answer}'.\n"
f"Let's try again, {name}!\n\n\n"
f"Let's try again, {name}!\n"
)

return