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

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

1 точки общо

4 успешни теста
1 неуспешни теста
Код

 1def organize(cars, students):
 2
 3    list_of_students = students
 4    list_of_cars = cars
 5    lenght_students = len(list_of_students)
 6    lenght_cars = len(list_of_cars)
 7
 8    if not (list_of_cars and list_of_students):
 9        return False
10    if lenght_students/ lenght_cars > 4:
11        return False
12    
13    
14
15    for car in list_of_cars:
16        for student in list_of_students:
17            if not student.car :
18                try:
19                    car.add_student(student)
20                    if not student.is_comfy():
21                        car.remove_student(student)
22
23                except EnvironmentError:
24                    continue
25   
26    for student in list_of_students:
27        if not student.is_comfy():
28            return False
29        
30    return True
31 

...F.
======================================================================
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.000s

FAILED (failures=1)

Дискусия
История

n1def organize (cars, students):n1def organize(cars, students):
22
3    list_of_students = students3    list_of_students = students
4    list_of_cars = cars4    list_of_cars = cars
5    lenght_students = len(list_of_students)5    lenght_students = len(list_of_students)
6    lenght_cars = len(list_of_cars)6    lenght_cars = len(list_of_cars)
77
8    if not (list_of_cars and list_of_students):8    if not (list_of_cars and list_of_students):
9        return False9        return False
10    if lenght_students/ lenght_cars > 4:10    if lenght_students/ lenght_cars > 4:
11        return False11        return False
12    12    
nn13    
1314
14    for car in list_of_cars:15    for car in list_of_cars:
15        for student in list_of_students:16        for student in list_of_students:
16            if not student.car :17            if not student.car :
17                try:18                try:
18                    car.add_student(student)19                    car.add_student(student)
19                    if not student.is_comfy():20                    if not student.is_comfy():
20                        car.remove_student(student)21                        car.remove_student(student)
n21 n22 
22                except EnvironmentError:23                except EnvironmentError:
23                    continue24                    continue
n24    n25   
25    for student in list_of_students:26    for student in list_of_students:
26        if not student.is_comfy():27        if not student.is_comfy():
27            return False28            return False
28        29        
29    return True30    return True
t30 t31 
31    
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op