Solution

Four-by-Four Skyscrapers

Show the problem again

Place a building of height 1, 2, 3 or 4 in each cell of a $4 \times 4$ grid so that every row and every column contains each height exactly once. A number on the edge of the grid says how many buildings are visible when you look along that row or column from that side; a taller building hides every shorter building behind it. The given clues are: - Looking down column 3 from the top: 1 building. - Looking down column 4 from the top: 2 buildings. - Looking up column 1 from the bottom: 2 buildings. - Looking up column 4 from the bottom: 1 building. - Looking along row 2 from the left: 1 building. - Looking along row 2 from the right: 3 buildings. Give the top row as a four-digit number, reading left to right.

Worked solution

A clue of 1 means the tallest building (height 4) stands at the near end. So there is a 4 in row 1 of column 3, in column 1 of row 2, and in row 4 of column 4; the 4 of column 2 must then be in row 3. Column 4 seen from the top shows exactly two buildings and ends in the 4, so its top cell hides everything between it and the 4: it is 3. Row 1 is therefore $\_\ \_\ 4\ 3$, with 1 and 2 in the first two cells, and the cells of column 4 in rows 2 and 3 are 1 and 2. Row 2 reads $4, a, b, c$ with $c \in \{1,2\}$ and $\{a,b,c\} = \{1,2,3\}$. Seen from the right it shows three buildings, which leaves only $(a,b,c) = (2,3,1)$, $(1,3,2)$ or $(3,1,2)$. Column 1 seen from the bottom shows two buildings, and its 4 is in row 2, so the cell in row 3 is hidden by the cell in row 4: the row 3 entry is smaller than the row 4 entry. In the first two options, row 1 and column 4 force row 3 to end with 2 or 1, the column 1 condition then forces row 3 to start with 1 or 2, and row 3 is left needing a 3 in column 3, but column 3 already has a 3 in row 2. Contradiction. In the third option, row 3 is $\_\ 4\ \_\ 1$ with 2 and 3 to place, and the column 1 condition forces 2 in column 1 (3 would need a taller cell below it), so row 3 is 2 4 3 1, column 1 continues with 3 in row 4 and 1 in row 1. The grid is 1 2 4 3 / 4 3 1 2 / 2 4 3 1 / 3 1 2 4. The top row is 1243.

Source: Skyscrapers (Towers) puzzles are a well-known Latin-square variant in wide circulation; this instance was written for AxiomIQ.