"""Functions which helps the locomotive engineer to keep track of the train.""" def get_list_of_wagons(*wagons_ids): """Return a list of wagons. :param: arbitrary number of wagons. :return: list - list of wagons. """ return list(wagons_ids) def fix_list_of_wagons(each_wagons_id, missing_wagons): """Fix the list of wagons. :param each_wagons_id: list - the list of wagons. :param missing_wagons: list - the list of missing wagons. :return: list - list of wagons. """ first, second, locomotive, *rest = each_wagons_id (*fixed_list,) = locomotive, *missing_wagons, *rest, first, second return fixed_list def add_missing_stops(route: dict, **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"],) = 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. """ # reordered_wagons: list[list[tuple]] = [] # grid_1: list = [] # grid_2: list = [] # grid_3: list = [] # for row in wagons_rows: # wagon_1, wagon_2, wagon_3 = row # grid_1.append(wagon_1) # grid_2.append(wagon_2) # grid_3.append(wagon_3) # reordered_wagons = [grid_1, grid_2, grid_3] # return reordered_wagons return [[row_1, row_2, row_3] for (row_1, row_2, row_3) in zip(*wagons_rows)]