2026-06-26

Problem — 2026-06-26

Medium

MediumCombinatorics

A chef is arranging 8 different spices in a row on a shelf, but there's a superstition in the kitchen: cinnamon and nutmeg must never be adjacent (they're said to "clash energies"), and likewise star anise and clove must never be adjacent. The other 4 spices have no restrictions. How many valid arrangements are there?

Enter the exact number of arrangements

Show solution
We'll use inclusion-exclusion. Let AA be the set of arrangements where cinnamon and nutmeg are adjacent, and BB be the set where star anise and clove are adjacent. **Total unrestricted arrangements:** 8!=403208! = 40320 **Computing ∣A∣|A|:** If cinnamon and nutmeg must be adjacent, treat them as a single "super-spice." We now have 7 objects to arrange: the CN-block and 6 others. These can be arranged in 7!7! ways. Within the block, C and N can be in 2 orders. So ∣A∣=7!⋅2=5040⋅2=10080|A| = 7! \cdot 2 = 5040 \cdot 2 = 10080. **Computing ∣B∣|B|:** By the same reasoning, ∣B∣=7!⋅2=10080|B| = 7! \cdot 2 = 10080. **Computing ∣A∩B∣|A \cap B|:** Both pairs must be adjacent. Treat CN as one block and SC (star anise-clove) as another block. We have 6 objects total: 2 blocks and 4 individual spices. These arrange in 6!6! ways. Each block has 2 internal orderings. So ∣A∩B∣=6!⋅2⋅2=720⋅4=2880|A \cap B| = 6! \cdot 2 \cdot 2 = 720 \cdot 4 = 2880. **By inclusion-exclusion:** The number of arrangements where at least one forbidden pair is adjacent is: |A \cup B| = |A| + |B| - |A \cap B| = 10080 + 10080 - 2880 = 17280 **Valid arrangements:** 8! - |A \cup B| = 40320 - 17280 = 23040