Skip to content

Commit 7927866

Browse files
committed
refactoring according to mentor's edits (gcd game)
1 parent 19ef077 commit 7927866

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

brain_games/games/gcd.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1+
from math import gcd
12
from brain_games.utils import get_random_number
23
from brain_games.game_engine import game_engine
34
from brain_games.constants import GCD_GAME_BRIEFING
45

56

6-
def get_greatest_common_divisor(num1, num2):
7-
while num2:
8-
num1, num2 = num2, num1 % num2
9-
return num1
10-
11-
127
def get_random_numbers_and_answer():
138
num1, num2 = get_random_number(), get_random_number()
149
question = f'{num1} {num2}'
15-
answer = str(get_greatest_common_divisor(num1, num2))
16-
return question, answer
10+
answer = gcd(num1, num2)
11+
return question, str(answer)
1712

1813

1914
def gcd_game():

brain_games/games/progression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def get_random_sequence_and_answer():
1010
sequence = []
1111
sequence.append(start_number)
1212
for i in range(8):
13-
sequence += [sequence[i] + random_step]
13+
sequence += [sequence[i] + int(random_step)]
1414
question = ''
1515
answer = get_random_choice(sequence)
1616
for i in range(len(sequence)):

0 commit comments

Comments
 (0)