[Locomotive Engineer] fix types in fix_wagon_depot function

I’m not sure I’m using this forum right. But i was sent here from the github issue.

I’ve found out that types in the docstring of the fix_wagon_depot function in the Locomotive Engineer exercise are misleading.

Instructions says:

Implement a function called fix_wagon_depot() that accepts a list of three items. Each list item is a sublist (or “row”) that contains three tuples. Each tuple is a (<wagon ID>, <wagon color>) pair.

Your function should return a list with the three “row” lists reordered to have the wagons swapped into their correct positions.

>>> fix_wagon_depot([
                    [(2, "red"), (4, "red"),(8, "red")],
                    [(5, "blue"),(9, "blue"),(13,"blue")],
                    [(3, "orange"),(7, "orange"), (11, "orange")],
                    ])

[
[(2, "red"),(5, "blue"),(3, "orange")],
[(4, "red"),(9, "blue"),(7, "orange")],
[(8, "red"),(13,"blue"),(11, "orange")]
]

So the types of a parameter and the return value of the function should both be list[list[tuple]] or even list[list[tuple[int, str]]]. But predefined code contains wrong types in the docstring:

def fix_wagon_depot(wagons_rows):
    """Fix the list of rows of wagons.
    :param wagons_rows: list[tuple] - the list of rows of wagons.
    :return: list[tuple] - list of rows of wagons.
    """
    pass

I suggest changing it to:

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.
    """
    pass
2 Likes

Yes, this is the right place to report this. What you find is an issue. I think we restructerd the data and forgot to update the params. I will look more into this.

2 Likes

Thanks for reporting, @ypypy28 :slightly_smiling_face:

2 Likes