---
title: "Constrained Surjective Functions from a 6-Set to a 4-Set"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-pie-constrained-surjections"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-11-27T16:30:00+05:30"
---

# Constrained Surjective Functions from a 6-Set to a 4-Set

Find the number of surjective (onto) functions $f: \{1, 2, 3, 4, 5, 6\} \to \{1, 2, 3, 4\}$ such that $f(1) \ne 1$ and $f(2) \ne 2$.

## Textbook Solution

First, count all surjective functions $\mathcal{S}$ from a $6$-element set onto a $4$-element set using Inclusion-Exclusion on the $4$ possible missed values in the codomain:
$$|\mathcal{S}| = 4^6 - \binom{4}{1}3^6 + \binom{4}{2}2^6 - \binom{4}{3}1^6 = 4096 - 4(729) + 6(64) - 4 = 1560.$$
Inside $\mathcal{S}$, let $A = \{f \in \mathcal{S} : f(1) = 1\}$ and $B = \{f \in \mathcal{S} : f(2) = 2\}$. We want $|\mathcal{S}| - |A| - |B| + |A \cap B|$.

1. **Compute $|A|$ and $|B|$**:
   In any onto function $f \in \mathcal{S}$, permuting the $4$ output labels $\{1, 2, 3, 4\}$ keeps $f$ surjective. Hence $f(1)$ takes each value $1, 2, 3, 4$ equally often:
   $$|A| = \frac{1560}{4} = 390.$$
   By the same symmetry on $f(2)$, $|B| = 390$.

2. **Compute $|A \cap B|$**:
   Here $f(1) = 1$ and $f(2) = 2$. Thus $1$ and $2$ are already in the image of $f$. For $f$ to be surjective, the remaining $4$ inputs $\{3, 4, 5, 6\}$ can map to any values in $\{1, 2, 3, 4\}$, provided **both** $3$ and $4$ appear at least once in their image.
   By Inclusion-Exclusion on missing $3$ or missing $4$ among all $4^4 = 256$ functions $\{3, 4, 5, 6\} \to \{1, 2, 3, 4\}$:
   $$|A \cap B| = 4^4 - 2\cdot 3^4 + 2^4 = 256 - 162 + 16 = 110.$$

Combining via Inclusion-Exclusion:
$$|\mathcal{S} \setminus (A \cup B)| = 1560 - 390 - 390 + 110 = 890.$$

## Vedic Shortcut

Check $|A| = 390$ directly in two pieces as a sanity check: if $f(1)=1$, then $\{2..6\}$ either hits all $4$ values ($4!S(5,4) = 24 \times 10 = 240$) or hits $\{2,3,4\}$ ($3!S(5,3) = 6 \times 25 = 150$), summing to $240 + 150 = 390$!
And for $|A \cap B|$, think of $\{3,4,5,6\}$ hitting $\{3,4\}$: either $3,4$ are hit with $0$ occurrences of $\{1,2\}$ ($2^4 - 2 = 14$), or with $\{1,2\}$ included ($256 - 162 + 16 = 110$).
Thus $1560 - 780 + 110 =$ **$890$**.

## Common Mistakes

- **Restricting $\{3,4,5,6\}$ to $\{3,4\}$ in $|A \cap B|$**: When $f(1)=1$ and $f(2)=2$, the remaining elements $\{3,4,5,6\}$ are still *allowed* to map to $1$ and $2$—they simply must cover $3$ and $4$. Restricting them to $\{3,4\}$ gives $2^4 - 2 = 14$ instead of $110$.
- **Using $1560 \times (3/4)^2$**: The events $f(1) \ne 1$ and $f(2) \ne 2$ are not independent because $f(1)=1$ helps fulfill surjectivity.