Предизвикателства > Осмодекемврийско пътуване > Решения > Решението на Димитър Христов

Резултати
1 точки от тестове
0 точки от учител

1 точки общо

3 успешни теста
2 неуспешни теста
Код

 1def organize(cars, students):
 2    
 3    if len(cars)*4 < len(students):
 4        return False
 5    
 6    if not students:
 7        return True
 8    
 9    student = students.pop(0)
10    result = False
11    for car in cars:
12        try:
13            car.add_student(student)
14        except EnvironmentError:
15            continue
16        if student.is_comfy():
17            result = organize(cars, students)
18        else:
19            car.remove_student(student)
20        if result:
21            return True
22    students.insert(0, student)
23    return False

...FE
======================================================================
ERROR: test_single_solution_case (test.TesFull)
Test a single-solution case.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 68, in test_single_solution_case
anti_rusalov_is(self, students[0].car, cars[0])
IndexError: list index out of range

======================================================================
FAIL: test_regular_case (test.TesFull)
Test a regular case.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 47, in test_regular_case
anti_rusalov_true(self, organize(cars, students))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 5 tests in 0.001s

FAILED (failures=1, errors=1)

Дискусия
История
Това решение има само една версия.