4. In each cell of the square field below, a building of height 1, 2, 3, 4, or 5 is placed so that the following rules are met:

- In each (horizontal) row and (vertical) column, each building height appears exactly once.
- The numbers on the sides of the square are the sums of the heights of the visible buildings. These are the buildings (partially) visible in the side view from the number on the side. For example, if the heights 1, 3, 2, 5, and 4 are in a row in that order, then from the left, the buildings with heights 1, 3, and 5 are visible, and from the right, the buildings with heights 4 and 5 are visible.

![](https://cdn.mathpix.com/cropped/2024_04_17_37097645698d56aa28c8g-2.jpg?height=460&width=460&top_left_y=250&top_left_x=1415)

6

How tall is the building that goes in the place of the question mark?
A) 1 tall
B) 2 tall
C) 3 tall
D) 4 tall
E) 5 tall
A4. B) 2 First note that the building of 5 stories is always visible. We first look at the middle column, where the 6 is written. It must hold that $6=1+5$: the first building you see is 1 story high, and behind it you see the building of 5 stories. No building can stand between them, because otherwise we would also see it from the side. In this way, we get the numbers in the first picture.

Now we look at the second row, where an 8 stands on the right side. The building of 1 story can only be in the second or fifth column due to the first requirement. If the 1 is in the fifth column, the 8 on the right side only works if the order is $4-3-5-2-1$. But that can't be, because there is already a 5 in the third column. So the 1 is in the second column. We can now only get a sum of 8 from the right side if the buildings of height 3 and 5 are visible. Therefore, the 3 is in the fifth column and due to the first requirement, the 5 is in the fourth column. This gives us the numbers as in the second picture.
![](https://cdn.mathpix.com/cropped/2024_04_17_b71e27e72afbe21d81ceg-2.jpg?height=492&width=1502&top_left_y=824&top_left_x=310)

Finally, we look at the 8 above the second column. We already see a 1 in the second row. This building cannot be visible. The visible buildings of this 8 are therefore also buildings of height 3 and 5. The building with height 3 comes in the top row and the 5 in the third row, because there is already a 5 in the fourth row and if the 5 were in the bottom row, the building of height 4 would also be visible.

We now have the numbers filled in as in the third picture. Continue filling in as you would a Sudoku, so that each number appears exactly once in each row and column. You can fill in the first column, the third column, and the middle row completely. Then you see that the number 2 comes at the question mark.