Skip to content

Commit c4a7c4c

Browse files
committed
fix autotest linting errors, rename variables
1 parent beef5e6 commit c4a7c4c

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

brain_games/constants.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
EVEN_GAME_BRIEFING = 'Answer "yes" if the number is even, otherwise answer "no".'
2-
CALC_GAME_BRIEFING = 'What is the result of the expression?'
3-
GCD_GAME_BRIEFING = 'Find the greatest common divisor of given numbers.'
4-
PROG_GAME_BRIEFING = 'What number is missing in the progression?'
5-
PRIME_GAME_BRIEFING = 'Answer "yes" if given number is prime. Otherwise answer "no".'
1+
EVEN_BRIEFING = 'Answer "yes" if the number is even, otherwise answer "no".'
2+
CALC_BRIEFING = 'What is the result of the expression?'
3+
GCD_BRIEFING = 'Find the greatest common divisor of given numbers.'
4+
PROG_BRIEFING = 'What number is missing in the progression?'
5+
PRIME_BRIEFING = 'Answer "yes" if given number is prime. Otherwise answer "no".'
66

77
NUMBER_OF_GAMES = 3
88
PROGRESSION_LENGTH = 9

brain_games/game_engine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44

55
def game_engine(get_question_and_answer, briefing):
6-
username = prompt.string('Welcome to the Brain Games!\n''May I have your name? ')
6+
username = prompt.string(
7+
'Welcome to the Brain Games!\n''May I have your name? '
8+
)
79
print(f'Hello, {username}!')
810
print(briefing)
911
for _ in range(const.NUMBER_OF_GAMES):

brain_games/games/calc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from random import choice
2-
from brain_games.utils import get_random_number
2+
from brain_games.utils import get_random_num
33
from brain_games.game_engine import game_engine
44
from brain_games.constants import CALC_GAME_BRIEFING
55

66

7-
def get_random_math_sym_and_calc_answer(num1: int, num2: int) -> list[str | int]:
7+
def get_random_math_sym_and_answer(num1: int, num2: int) -> list[str | int]:
88
return choice([
99
['+', num1 + num2],
1010
['-', num1 - num2],
@@ -13,8 +13,8 @@ def get_random_math_sym_and_calc_answer(num1: int, num2: int) -> list[str | int]
1313

1414

1515
def get_expression_and_answer():
16-
num1, num2 = get_random_number(max_range=15), get_random_number(max_range=10)
17-
random_math_symbol, answer = get_random_math_sym_and_calc_answer(num1, num2)
16+
num1, num2 = get_random_num(max_range=15), get_random_num(max_range=10)
17+
random_math_symbol, answer = get_random_math_sym_and_answer(num1, num2)
1818
question = f'{num1} {random_math_symbol} {num2}'
1919
return question, str(answer)
2020

brain_games/games/even.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
from brain_games.utils import get_random_number
1+
from brain_games.utils import get_random_num
22
from brain_games.game_engine import game_engine
3-
from brain_games.constants import EVEN_GAME_BRIEFING
3+
from brain_games.constants import EVEN_BRIEFING
44

55

66
def is_even(number: int) -> bool:
77
return number % 2 == 0
88

99

1010
def get_random_num_and_answer():
11-
random_number = get_random_number()
11+
random_number = get_random_num()
1212
even_check = 'yes' if is_even(random_number) else 'no'
1313
return random_number, even_check
1414

1515

1616
def even_game():
17-
game_engine(get_random_num_and_answer, EVEN_GAME_BRIEFING)
17+
game_engine(get_random_num_and_answer, EVEN_BRIEFING)

brain_games/games/gcd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from math import gcd
22
from brain_games.utils import get_random_number
33
from brain_games.game_engine import game_engine
4-
from brain_games.constants import GCD_GAME_BRIEFING
4+
from brain_games.constants import GCD_BRIEFING
55

66

77
def get_random_numbers_and_answer():
@@ -12,4 +12,4 @@ def get_random_numbers_and_answer():
1212

1313

1414
def gcd_game():
15-
game_engine(get_random_numbers_and_answer, GCD_GAME_BRIEFING)
15+
game_engine(get_random_numbers_and_answer, GCD_BRIEFING)

brain_games/games/prime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from brain_games.utils import get_random_number
22
from brain_games.game_engine import game_engine
3-
from brain_games.constants import PRIME_GAME_BRIEFING
3+
from brain_games.constants import PRIME_BRIEFING
44

55

66
def is_prime(number):
@@ -22,4 +22,4 @@ def get_random_number_and_answer():
2222

2323

2424
def prime_game():
25-
game_engine(get_random_number_and_answer, PRIME_GAME_BRIEFING)
25+
game_engine(get_random_number_and_answer, PRIME_BRIEFING)

brain_games/games/progression.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
from brain_games.utils import get_random_number
33
from brain_games.game_engine import game_engine
44
from brain_games.constants import PROGRESSION_LENGTH
5-
from brain_games.constants import PROG_GAME_BRIEFING
5+
from brain_games.constants import PROG_BRIEFING
66

77

88
def get_random_sequence_and_answer():
99
random_step = get_random_number(min_range=2, max_range=5)
1010
start_number = get_random_number(max_range=15)
11-
sequence = []
12-
sequence.append(start_number)
11+
seq = []
12+
seq.append(start_number)
1313
for i in range(PROGRESSION_LENGTH):
14-
sequence += [sequence[i] + random_step]
15-
missed_num_index = choice(sequence)
14+
seq += [seq[i] + random_step]
15+
missed_index = choice(seq)
1616
question = ''
17-
for i in range(len(sequence)):
18-
print(sequence[i])
19-
question += ' ' + str(sequence[i]) if sequence[i] != missed_num_index else ' ..'
20-
return question.strip(), str(missed_num_index)
17+
for i in range(len(seq)):
18+
print(seq[i])
19+
question += ' ' + str(seq[i]) if seq[i] != missed_index else ' ..'
20+
return question.strip(), str(missed_index)
2121

2222

2323
def progression_game():
24-
game_engine(get_random_sequence_and_answer, PROG_GAME_BRIEFING)
24+
game_engine(get_random_sequence_and_answer, PROG_BRIEFING)

brain_games/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import random
22

33

4-
def get_random_number(min_range: int = 1, max_range: int = 100) -> int:
4+
def get_random_num(min_range: int = 1, max_range: int = 100) -> int:
55
random_number = random.randint(min_range, max_range)
66
return random_number

0 commit comments

Comments
 (0)