Solution
Not First, Not Last
Show the problem again
Six people, including Ann and Bob, stand in a single row for a photograph. Ann refuses to stand at the left end, and Bob refuses to stand at the right end. In how many orders can the six people stand? Give an integer.
Worked solution
The answer is 504. Use inclusion-exclusion. There are 6! = 720 orders in total. Ann is at the left end in 5! = 120 of them, and Bob is at the right end in another 120. Both happen at once in 4! = 24 orders, which were subtracted twice. So the number of acceptable orders is 720 − 120 − 120 + 24 = 504.
Source: Classic counting exercise in wide circulation; no traceable original source. Statement written for AxiomIQ.