Абдикашева Вилена Ринатовна, 411 группа RaceTesting 10294
Алдабергенов Руслан Даниярович, 411 RaceTesting 9747
f1from itertools import cyclef1from itertools import cycle
22
3def speed(path, stops, times):3def speed(path, stops, times):
n4    distance_iter = iter(path)n4    path_iter = iter(path)
5    stop_sequence = cycle(stops)5    stops_iter = cycle(stops)
6    time_iter = iter(times)6    times_iter = iter(times)
7    while True:7    while True:
n8        report_stops = next(stop_sequence)n8        stop_count = next(stops_iter)
9        total_distance = 09        segment_distance = 0
10        segments_count = 010        distances_covered = 0
11        for _ in range(report_stops):11        for _ in range(stop_count):
12            segment = next(distance_iter, None)12            distance = next(path_iter, None)
13            if segment is None:13            if distance is None:
14                break14                break
n15            total_distance += segmentn15            segment_distance += distance
16            segments_count += 116            distances_covered += 1
17        if segments_count == 0:17        if distances_covered == 0:
18            return18            return
n19        travel_time = next(time_iter, None)n19        time = next(times_iter, None)
20        if travel_time is None:20        if time is None:
21            yield (total_distance / segments_count)21            yield (segment_distance / distances_covered)
22            return22            return
t23        if travel_time > 0:t23        if time > 0:
24            yield (total_distance / travel_time)24            yield (segment_distance / time)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op