You have to restore the broken window glass.
You are given a list of lists as input values. Each list of integers represents a missing piece. It always has a horizontal base, which forms the upper or lower side of the window. Each integer represents the height from the base and is a value measured at equal intervals from the left edge. Therefore, the length of the list represents the width.
The answer should be returned in the two lists (the upper list and lower list in that order).
- In the output each piece is represented in the order given as input (starting with 0).
- The bases of the pieces in the same list must always be adjacent to each other.
- (In other words, one piece doesn't form both the upper and lower side of the window.)
- It is not necessary to consider turning over piece.
broken_window([[1, 0], [1, 0]] == (, ) # or (, ) broken_window([[4, 0], [0, 1, 4, 0], [3, 0], [0, 3, 4, 1]] == ([1, 2], [0, 3]) # or ([3, 0], [2, 1])
Input: The pieces of the broken window (list of lists of integers).
Output: The list of top pieces and list of bottom pieces (both are lists of integers).
- 2 ≤ len(input)
- 2 ≤ len(piece)
- 1 ≤ width of window ≤ 20
- 1 ≤ height of window ≤ 18