-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocomotive_engineer.py
52 lines (36 loc) · 1.51 KB
/
locomotive_engineer.py
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
50
51
52
"""Functions which helps the locomotive engineer to keep track of the train."""
def get_list_of_wagons(*wagons):
"""Return a list of wagons.
:param: arbitrary number of wagons.
:return: list - list of wagons.
"""
return list(wagons)
def fix_list_of_wagons(each_wagons_id, missing_wagons):
"""Fix the list of wagons.
:parm each_wagons_id: list - the list of wagons.
:parm missing_wagons: list - the list of missing wagons.
:return: list - list of wagons.
"""
moved_wagon1,moved_wagon2,locomotive,*rest = each_wagons_id
return [locomotive,*missing_wagons,*rest,moved_wagon1,moved_wagon2]
def add_missing_stops(route,**kwargs):
"""Add missing stops to route dict.
:param route: dict - the dict of routing information.
:param: arbitrary number of stops.
:return: dict - updated route dictionary.
"""
route["stops"]=list(kwargs.values())
return route
def extend_route_information(route, more_route_information):
"""Extend route information with more_route_information.
:param route: dict - the route information.
:param more_route_information: dict - extra route information.
:return: dict - extended route information.
"""
return {**route, **more_route_information}
def fix_wagon_depot(wagons_rows):
"""Fix the list of rows of wagons.
:param wagons_rows: list[list[tuple]] - the list of rows of wagons.
:return: list[list[tuple]] - list of rows of wagons.
"""
return list(map(list, zip(*wagons_rows)))