---
title: "Derangements of 6 Elements with Two Extra Forbidden Positions"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-pie-constrained-derangements"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-11-27T13:30:00+05:30"
---

# Derangements of 6 Elements with Two Extra Forbidden Positions

Find the number of permutations $(a_1, a_2, a_3, a_4, a_5, a_6)$ of $\{1, 2, 3, 4, 5, 6\}$ such that $a_i \ne i$ for every $i \in \{1, 2, 3, 4, 5, 6\}$, and additionally $a_1 \ne 2$ and $a_2 \ne 3$.

## Textbook Solution

Let $\mathcal{D}_6$ be the set of all derangements of $\{1, 2, 3, 4, 5, 6\}$. Using the derangement recurrence $D_n = (n-1)(D_{n-1} + D_{n-2})$ with $D_1 = 0, D_2 = 1$:
$$D_3 = 2, \quad D_4 = 9, \quad D_5 = 44, \quad D_6 = 5(44 + 9) = 265.$$
Within $\mathcal{D}_6$, define:
- $A = \{\pi \in \mathcal{D}_6 : a_1 = 2\}$,
- $B = \{\pi \in \mathcal{D}_6 : a_2 = 3\}$.

We seek $|\mathcal{D}_6| - |A| - |B| + |A \cap B|$.

1. **Compute $|A|$ and $|B|$**:
   In any derangement $\pi \in \mathcal{D}_6$, $a_1$ can take any of the $5$ values in $\{2, 3, 4, 5, 6\}$. Relabeling any two elements in $\{2, 3, 4, 5, 6\}$ preserves the derangement property $a_i \ne i$ for all $i$. By symmetry, all $5$ values occur equally often at $a_1$:
   $$|A| = \frac{D_6}{5} = \frac{265}{5} = 53.$$
   Similarly, by cyclic symmetry, $|B| = \frac{D_6}{5} = 53$.

2. **Compute $|A \cap B|$**:
   Here $a_1 = 2$ and $a_2 = 3$. The remaining values $\{1, 4, 5, 6\}$ must be assigned to positions $\{3, 4, 5, 6\}$ with the restrictions $a_4 \ne 4$, $a_5 \ne 5$, and $a_6 \ne 6$ (note $a_3$ has no restriction since $3$ is already used at position $2$).
   By Inclusion-Exclusion on the $3$ forbidden fixed points $\{a_4=4, a_5=5, a_6=6\}$ among all $4! = 24$ bijections:
   $$|A \cap B| = 4! - \binom{3}{1}3! + \binom{3}{2}2! - \binom{3}{3}1! = 24 - 18 + 6 - 1 = 11.$$

Applying Inclusion-Exclusion:
$$|\mathcal{D}_6 \setminus (A \cup B)| = 265 - 53 - 53 + 11 = 170.$$

## Vedic Shortcut

You don't need an 8-set PIE! Work **inside** $\mathcal{D}_6$ using the two quick identities:
1. $D_6 = 265$ is divisible by $5$, so each of the $5$ valid choices for $a_1$ has count $265/5 = 53$. Thus $|A| = |B| = 53$.
2. For $|A \cap B|$, split on $a_3$:
   - If $a_3 = 1$, $\{4,5,6\}$ are deranged in $D_3 = 2$ ways.
   - If $a_3 \in \{4,5,6\}$ ($3$ choices, say $a_3 = 4$), $\{1,5,6\}$ fill positions $\{4,5,6\}$ with $a_5\ne 5, a_6\ne 6$. Relabeling $1 \leftrightarrow 4$ asks for derangements of $\{4,5,6\}$ except $a_4$ CAN be $4$, wait: $a_4$ can be $1, 5,$ or $6$: that's $D_3 + D_2 = 2 + 1 = 3$ ways!
   Total $|A \cap B| = 2 + 3(3) = 11$.
Answer $= 265 - 2(53) + 11 =$ **$170$**.

## Common Mistakes

- **Treating $|A \cap B|$ as $D_4 = 9$**: Because $a_1 = 2$ and $a_2 = 3$ leave value $1$ for position $3$, position $3$ has NO forbidden value (since $3$ is already placed at $a_2$). Only $3$ elements have forbidden positions, giving $11$ instead of $D_4 = 9$.
- **Assuming $a_1 = 2$ and $a_2 = 3$ are independent**: Multiplying $(4/5)^2 \times 265$ fails because $a_1 = 2$ affects the availability of values for $a_2$.