import random
from brain_games.engine import run_game


def play():
    RULE = 'What is the result of the expression?'
    run_game(RULE, generate_data)


def generate_data():
    operation = random.choice(['+', '-', '*'])
    x = random.randrange(100)
    y = random.randrange(100)
    if operation == '+':
        correct_answer = x + y
    elif operation == '-':
        correct_answer = x - y
    else:
        correct_answer = x * y
    expression = '{} {} {}'.format(x, operation, y)
    return expression, str(correct_answer)
