Skip to content

Commit 2f7d98e

Browse files
touch brain_gcd.py and gcd.py
1 parent 172dda2 commit 2f7d98e

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

brain_games/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
def welcome_user(game_intro=''):
55
print("Welcome to the Brain Games!")
6-
if game_intro:
7-
print(f"{game_intro}")
8-
print()
96
name = prompt.string('May I have your name? ')
107
print(f'Hello, {name}!')
8+
if game_intro:
9+
print(f"{game_intro}")
10+
1111
return name
1212

1313

brain_games/games/gcd.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from random import randint
2+
3+
RULES = 'Find the greatest common divisor of given numbers.'
4+
5+
6+
def start_game():
7+
n1, n2 = randint(1, 100), randint(1, 100)
8+
9+
max_divisor = min(n1, n2)
10+
11+
for num in range(1, max_divisor + 1):
12+
if n1 % num == 0 and n2 % num == 0:
13+
answer = num
14+
15+
question = f'{n1} {n2}'
16+
17+
return (question, str(answer))

brain_games/scripts/brain_gcd.py

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 gcd
3+
4+
5+
def main():
6+
game_start(gcd)
7+
8+
9+
if __name__ == "__main__":
10+
main()

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ 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"

0 commit comments

Comments
 (0)