File size: 1,378 Bytes
790a22c
 
 
 
 
3dc9376
790a22c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3dc9376
790a22c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from random import random


import random

def generate_hint(question_numbers, right_answer, number_correct, number_incorrect, level, hints_used):
    ordinal_number = question_numbers[1]
    equation = right_answer - 2 * ordinal_number - 1
    least_number = equation if equation > 0 else 0
    seq_before_answer = " ".join(
        [str(num) for num in range(right_answer - ordinal_number, least_number, -ordinal_number)][::-1]
    )
    seq_after_answer = " ".join(
        [str(num) for num in range(right_answer + ordinal_number, right_answer + 2 * ordinal_number + 1, ordinal_number)]
    )
    hints = [
        f"What number will fill the gap in a sequence {seq_before_answer} ... {seq_after_answer}?",
        f"What number is {ordinal_number} in the account after {right_answer - ordinal_number}?",
        f"What number is {ordinal_number} in the account before {right_answer + ordinal_number}?",
        f"What number is greater than {right_answer - 1} and less than {right_answer + 1}?"
    ]
    random_hint = random.choice(hints)
    hints_used += 1

    data_to_return = {
        "text": random_hint,
        "question_numbers": question_numbers,
        "right_answer": right_answer,
        'number_correct': number_correct,
        'number_incorrect': number_incorrect,
        'level': level,
        "hints_used": hints_used
    }
    return data_to_return