Spaces:
Sleeping
Sleeping
File size: 1,917 Bytes
d2213a5 | 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """Генератор задач: часы со стрелками"""
from core.base_generator import BaseTaskGenerator
from models.task import Task
from fractions import Fraction
from config import COMPLEXITY_CONFIG
import random
class ClockGenerator(BaseTaskGenerator):
"""Генератор задач про часы со стрелками"""
def generate(self) -> Task:
"""Генерация задачи"""
config = COMPLEXITY_CONFIG[self.complexity]
start_hour = random.randint(1, 11)
interval_length = random.randint(2, 6)
end_hour = (start_hour + interval_length) % 12
if end_hour == 0:
end_hour = 12
question = f"Механические часы с двенадцатичасовым циферблатом в какой-то момент сломались и перестали ходить. Найдите вероятность того, что часовая стрелка застыла, достигнув отметки {start_hour}, но не дойдя до отметки {end_hour} часов."
favorable = interval_length
total = 12
answer_fraction = Fraction(favorable, total)
answer = round(float(answer_fraction), 2)
steps = [
f"1. Полный круг циферблата: 12 часов",
f"2. Интервал от {start_hour} до {end_hour}: {interval_length}",
f"3. Вероятность = {interval_length}/12 = {answer_fraction}"
]
return Task(
type='clock',
question=question,
answer=answer,
answer_fraction=str(answer_fraction),
solution=f"Вероятность = {interval_length}/12 = {answer_fraction}",
steps=steps,
complexity=self.complexity
)
def get_type(self) -> str:
return 'clock' |