random.shuffle(random_order)
for i in random_order:
    student = students[i]
if student.dates[task]:
    continue
preferred = get_favorite_day(student, lowest_acceptable, spread_weight,
    tasks_to_spread)
for date_nr in preferred:
    date = dates[date_nr]
if date.is_available(task, student.count, lowest_acceptable == 1):
    date.set_student(task, student.count)
student.dates[task] = date
break
start_at = 5
while start_at > 1:
    lowest_acceptable = start_at
while lowest_acceptable > 0:
    fill('A', lowest_acceptable, spread_weight, 'AAB')
fill('B', lowest_acceptable, spread_weight, 'ABB')
if lowest_acceptable == 1:
    fill('C', lowest_acceptable, spread_weight_C, 'C')
lowest_acceptable -= 1
Максимизация комбинации ряда значений