Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Bernd Kreussler (MIC Limerick) 1 October 2011 Problem of the Month September 2011 In Figure 1 you can see 9 rectangles, namely How many rectangles can you see in Figure 2? Figure 1 Figure 2 Solution 1: If you thought about this problem, you probably realised that the difficulty is not to overlook a rectangle and to make sure you don’t double count any rectangle. Here is one way of systematic counting which ensures that the count is correct. We first observe that the rectangle size can be anything from 1 × 1 up to 6 × 3. To say it more precisely, the size of a possible rectangle is a × b with 1 ≤ a ≤ 6 and 1 ≤ b ≤ 3. Here a 3 × 2 rectangle is meant to be three little squares wide and two little squares high: 3 × 2 rectangle Now we want to find the number of a × b rectangles inside Figure 2. To count them, we simply count the possible positions of its top left square. For example, if we mark the top left little square in our 3 × 2 rectangle and the possible position in Figure 2 with a dot, we obtain b b b b b b b b b Possible positions of 3 × 2 rectangles Clearly, the top left square cannot be in the last row as the 3 × 2 rectangle consists of two rows. Similarly, the top left square cannot be in one of the last two columns as the 3 × 2 rectangle has three columns. For the 3 × 2 rectangle we therefore find 4 · 2 = 8 possible positions. In general, the top left square of an a×b rectangle cannot end up in any of the bottom b − 1 rows or in the right a − 1 columns in Figure 2. Therefore, the corresponding dot must be in the first 3 − (b − 1) = 4 − b rows and in the first 6 − (a − 1) = 7 − a columns. This means, there are (7−a)(4−b) possible positions for an a×b rectangle. From this we calculate the following table. a 1 1 1 b 1 2 3 (7 − a)(4 − b) 18 12 6 2 2 2 3 3 1 2 3 1 2 15 10 5 12 8 3 4 3 1 4 9 4 4 5 2 3 1 6 3 6 5 5 2 3 4 2 6 6 6 1 2 3 3 2 1 To finish off, we just need to add the numbers in the last row. There are 18 + 12 + 6 + 15 + 10 + 5 + 12 + 8 + 4 + 9 + 6 + 3 + 6 + 4 + 2 + 3 + 2 + 1 = 126 rectangles in Figure 2. 1 Solution 2: This solution tries to make the count a bit smarter. The starting point is the observation that any rectangle is determined by a pair of opposite vertices, see Figure 3. b b b or b Figure 3 Therefore, counting rectangles boils down to finding the number of possibilities to pick two points in the given grid which form the opposite vertices of a rectangle. As there are 7 · 4 = 28 vertices in the grid, we have 28 = 378 possibilities to chose a 2 pair of such vertices. However, not all of them determine a rectangle. Namely, if two vertices are on the same horizontal or vertical line, they will not form a rectangle. Let’s count the number of such possibilities. There are 7 vertical lines, on each we have 4 vertices. Therefore, there are 7 · 42 = 7 · 6 = 42 pairs of vertices both of which are on the same horizontal line. Similarly, as we have 4 vertical lines with 7 vertices each, there are 4 · 72 = 4 · 21 = 84 pairs of vertices to be excluded. Altogether, this leaves us with 378 − 42 − 84 = 252 pairs of vertices which define a rectangle. As we can see in Figure 3, for each rectangle there are two different pairs of vertices which define it. Hence, to count the rectangles correctly, we have to divide the number of pairs of vertices by to and obtain 252 ÷ 2 = 126 rectangles in Figure 2. Solution 3: This is the shortest and most elegant solution I know. The key observation is that any rectangular box is determined by the two horizontal lines and the two vertical lines which contain the four sides of the rectangle, see Figure 4. Figure 4 To count the rectangles, we therefore only have to find out in how many ways we can pick two vertical lines and in how many way we can pick two horizontal lines and then multiply the two numbers. As there are 7 possible positions for a vertical line, there are 72 = 21 possibilities to pick two vertical lines. For the horizontal lines, we have 4 possible positions, so we have 42 = 6 possibilities to pick two of them. Therefore, there are 21 · 6 = 126 rectangles in Figure 2. 2