The squares in a grid of squares are each colored either solid red, white, or blue. In how many ways can this be done so that no square colored red shares a side with a square colored blue?
- A)
- B)
- C)
- D)
- E)
Answer
E
Key insight
Diagonal squares do not share a side. Color one diagonal pair first; each remaining square touches both of them, so the two can be chosen separately.
Solution
Number the squares like this:
Write R, W, B for red, white, blue.
- Who touches whom. The pairs of squares that share a side are –, –, – and –. Squares and are diagonal: they touch only at a corner, so they do not share a side. The same is true of squares and .
So square has exactly two neighbors, squares and . Square has the same two neighbors, squares and .
- The plan. Color squares and first. They do not share a side, so any colors are allowed there. After that, square only has to get along with squares and , and so does square . Squares and do not affect each other, so we can count the choices for each and multiply.
3. The rule for square (and for square ).
- White is always allowed.
- Red is allowed when neither neighbor is blue.
- Blue is allowed when neither neighbor is red.
- Go through the cases for squares and .
| Squares and | Ways to color them | Colors allowed for square | Ways for squares and | Colorings |
|---|---|---|---|---|
| both white (WW) | R, W, B | |||
| some red, no blue (RR, RW, WR) | R, W | |||
| some blue, no red (BB, BW, WB) | W, B | |||
| one red, one blue (RB, BR) | W |
Check that no case is missing: , and there are ways to color two squares with three colors.
5. Add.
The answer is .
Why this works
In a grid each square has two neighbors, and the two squares on a diagonal have the same two neighbors. Once one diagonal is colored, the other two squares no longer depend on each other, so their choices multiply. In coloring problems, look for a few squares to color first that separate the rest into independent pieces.
Alternative approach
Sort the colorings by which colors appear.
- No red anywhere. Each square is white or blue, and nothing can go wrong: colorings.
- No blue anywhere. Each square is white or red: colorings.
- Counted twice. The all-white coloring is in both groups. So the colorings that are missing red or missing blue number .
- Both red and blue appear. Pick any blue square. Its two side neighbors cannot be red, so the only place a red square can be is diagonally across from it. In the same way, that red square's two side neighbors cannot be blue. Those two neighbors are the other two squares, and they are now neither red nor blue, so they are white. So the coloring is: one red, the square diagonally across blue, the other two white. The red square can be any of the squares, giving colorings.
- Total. .
The trap
Treating diagonal squares as neighbors. They touch only at a corner, so red and blue on opposite corners (with white on the other two) is allowed; leaving those 4 out gives 31.
Concise solution
Label the squares (top row) and (bottom row). Squares and each share sides with exactly squares and , and not with each other. Color squares and first; then squares and are chosen separately.
- and both white ( way): squares and are free, .
- Red but no blue on and ( ways): squares and are red or white, each, total .
- Blue but no red on and ( ways): total in the same way.
- One red and one blue on and ( ways): squares and must be white, total .
Altogether .
The answer is .
Review in the AoPS books
- Introduction to Counting & Probability, Chapter 5: More With Combinations (§5.2)
- Introduction to Counting & Probability, Chapter 1: Counting Is Arithmetic
- Introduction to Counting & Probability, Chapter 2: Basic Counting Techniques (§2.2)
- Prealgebra, Chapter 14: Counting (§14.3)
Techniques
Split into exhaustive cases and handle each