All the possibilities can found this way:
1) Start with the 1-story building
2) For each of the other buildings from 2 to 10, insert anywhere into the list such that it does not obscure any other buildings
For step 1, there will be 1 possibility.
For step 2, we will multiply the possibilities for each building we insert into the list. The 2-story building can go in front of or behind the 1. The 3-story building can go in front of the 2 or in the very back. The 4-story building can go in front of the 3 or in the very back. Continue like this to the last building.
As you might notice, there is a pattern in the number of possibilities: there are always 2 for each building. The number of possibilities is therefore equal to this product:
1*2*2*2*2*2*2*2*2*2 = 512
For the second question, going through the same steps, we will arrive at this product:
1*2*3*3*3*3*3*3*3*3 = 13122
For the third question,
1*2*3*4*4*4*4*4*4*4 = 98304
The general solution for N buildings, where a building is obscured if and only if it is directly behind a building M or more stories higher, and where M and N are positive integers and M ≤ N:
M! * M^(N-M) |