If we take a front view look at a row of apartments standing next to each other, we see that their number of floors varies. We can therefore describe the row of apartments as a sequence (list or tuple) of natural numbers (int) that indicate the number of floors in each apartment (listed from left to right). This way, the sequence $$[1, 4, 3, 2, 3, 1]$$ represents the following row of apartments.

gebouwen

Those apartments look quite boring, so we decide to make them more colorful. On each floor, we paint as many apartments as possible in the same color using a single horizontal brush stroke. We always change color when we change floors or when there's a gap between two apartments on a given floor.

penseelstreken

If we color the apartments $$[1, 4, 3, 2, 3, 1]$$ bottom up, we start painting the first floor of all six apartments in blue with a first stroke. With a second stroke we paint the second floor of four apartments in yellow. The third stroke covers the third floor of two apartments in purple and a fourth stroke paints the third floor of one more apartment in green. Finally, we need a fifth stroke to give the fourth floor of one apartment an orange color. So in total we need five brush strokes to paint all apartments in five different colors.

Assignment

A row of apartments is represented as a sequence (list or tuple) of natural numbers (int) that indicate the number of floors in each apartment (listed from left to right). Your task:

Example

>>> apartments = (1, 4, 3, 2, 3, 1)
>>> floors(apartments)
[[False, True, False, False, False, False], [False, True, True, False, True, False], [False, True, True, True, True, False], [True, True, True, True, True, True]]

>>> print(front_view(apartments, air='~'))
~~~~###~~~~~~~~~~~~~~~~
~~~~###~###~~~~~###~~~~
~~~~###~###~###~###~~~~
###~###~###~###~###~###
>>> print(front_view(apartments, width=4, distance=0, apartment='<', air="-"))
----<<<<----------------
----<<<<<<<<----<<<<----
----<<<<<<<<<<<<<<<<----
<<<<<<<<<<<<<<<<<<<<<<<<

>>> brush_strokes(apartments)
5