How many distinct ways can four books labeled A, B, C, and D be stacked vertically so that books A and B are never placed next to each other?
Explanation
First, calculate the total number of ways to arrange the four books, which is 4! = 24. Next, find the number of arrangements where A and B are together by treating them as a single unit, giving 3! × 2! = 12. Subtracting these from the total, the number of arrangements where A and B are not adjacent is 24 - 12 = 12.