---
title: "4-Element Subsets of {1..18} with Minimum Gap 3"
organization: "NityaDhi Digital Mathematics Lab (Asa Edtech Private Limited)"
url: "https://www.nityadhi.com/problems/hard-olympiad-nt-w1-stars-bars-gap-compression"
board: "Olympiad"
grade: "Olympiad"
published_at: "2026-11-27T10:30:00+05:30"
---

# 4-Element Subsets of {1..18} with Minimum Gap 3

Find the number of $4$-element subsets $\{a, b, c, d\} \subseteq \{1, 2, \dots, 18\}$ such that $|x - y| \ge 3$ for every pair of distinct elements $x, y$ in the subset.

## Textbook Solution

Order the elements of the subset as $1 \le a < b < c < d \le 18$.
The condition $|x - y| \ge 3$ for all distinct pairs is equivalent to requiring the three consecutive gaps to be at least $3$:
$$b - a \ge 3, \quad c - b \ge 3, \quad d - c \ge 3.$$
Define the non-negative gap variables:
$$y_1 = a - 1 \ge 0, \quad y_2 = (b - a) - 3 \ge 0, \quad y_3 = (c - b) - 3 \ge 0, \quad y_4 = (d - c) - 3 \ge 0, \quad y_5 = 18 - d \ge 0.$$
Summing these five equations telescopes all variables $a, b, c, d$:
$$y_1 + y_2 + y_3 + y_4 + y_5 = (18 - 1) - (3 + 3 + 3) = 17 - 9 = 8.$$
Every non-negative integer solution $(y_1, y_2, y_3, y_4, y_5)$ uniquely determines a valid subset $\{a, b, c, d\}$.
By Stars and Bars, the number of solutions is
$$\binom{8 + 5 - 1}{5 - 1} = \binom{12}{4} = \frac{12 \times 11 \times 10 \times 9}{24} = 495.$$

## Vedic Shortcut

Use the **Coordinate Shift Bijection**:
Map $(a, b, c, d) \mapsto (a, b - 2, c - 4, d - 6)$.
Notice:
- $b - a \ge 3 \iff (b - 2) > a$,
- $c - b \ge 3 \iff (c - 4) > (b - 2)$,
- $d - c \ge 3 \iff (d - 6) > (c - 4)$,
- $d \le 18 \iff d - 6 \le 12$.
This is a 1-to-1 bijection with strictly increasing $4$-tuples $1 \le a' < b' < c' < d' \le 12$, whose count is immediately $\binom{12}{4} =$ **$495$**!
(In general, $k$-subsets of $\{1..n\}$ with minimum gap $g$ equal $\binom{n - (k-1)(g-1)}{k}$.)

## Common Mistakes

- **Using $g$ instead of $g - 1$ in the shift**: Subtracting $3$ instead of $2$ at each step maps to $\le$ instead of $<$ and yields $\binom{9}{4} = 126$, losing valid subsets like $\{1, 4, 7, 10\}$.
- **Forgetting the outer endpoints**: Counting only $3$ gaps without including $y_1 = a - 1$ and $y_5 = 18 - d$.