Mathematics (JEE)HardCodeforces Div2 D

How many permutations of {1, 2, ..., 8} have no two adjacent entries whose values differ by exactly 1 (that is, |p(i) - p(i+1)| != 1 for every i from 1 to 7)?

  1. A. 7208
  2. B. 5242
  3. C. 6748
  4. D. 40320

Correct answer: B. 5242

Checking all 8! = 40320 permutations against the rule |p(i) - p(i+1)| != 1 for all 7 adjacent pairs leaves 5242 permutations.

More Permutations, Combinations and Probability questions

Exams that ask this topic