A catalogue of constructions that recur across constructive problems.
Permutations
| Goal | Construction |
|---|---|
| all distinct | (alternate the ends) |
| No fixed points (derangement) | shift by 1: |
| Adjacent elements differ by | odd positions first, then even |
| all distinct mod | (needs odd) |
| Maximum | reverse the two halves |
| Every prefix sum distinct mod | pattern |
| Exactly inversions | sort, then reverse a suitable prefix and adjust |
| distinct adjacent differences |
Alternating the extremes () is the single most reusable permutation construction — it maximises adjacent differences and separates values that must not be close.
Grids and matrices
| Goal | Construction |
|---|---|
| Latin square | |
| Two orthogonal Latin squares | and , for odd |
| Magic square, odd | the Siamese method (move up-right, drop down on collision) |
| All row and column sums equal | a circulant matrix |
| No two adjacent equal | chessboard colouring |
| Every has all four values | tile with a fixed block |
| Fill so all rows/columns are distinct | again |
Sequences
| Goal | Construction |
|---|---|
| All pairwise sums distinct (Sidon set) | powers of 2, or -based |
| All subset sums distinct | |
| Prefix sums all distinct | strictly positive values |
| No three in arithmetic progression | base-3 digits avoiding 2 (the greedy/Stanley sequence) |
| Sum with distinct positives | , then |
| Maximum gcd of a partition | multiples of the intended gcd |
| All XOR-distinct | a linear basis |
Graphs
| Goal | Construction |
|---|---|
| Exactly edges, connected | a path plus extra edges |
| -regular graph | a circulant: connect to |
| Bipartite with given degrees | Gale-Ryser condition, then greedy |
| Given degree sequence | Erdős-Gallai condition, then Havel-Hakimi |
| Diameter exactly | a path of length , everything else attached to the middle |
| Exactly components | a clique of the right size plus isolated vertices |
| Tree with given degrees | Prüfer code with the right multiplicities |
| Maximum edges, no triangle | complete bipartite (Turán) |
| Maximum edges, no | the Turán graph — a balanced -partite complete graph |
Havel-Hakimi for realising a degree sequence: repeatedly take the highest-degree vertex, connect it to the next highest, decrement, and recurse.
Number-theoretic
| Goal | Construction |
|---|---|
| numbers, pairwise coprime | distinct primes, or (Fermat numbers) |
| numbers with gcd and lcm | scale a construction by |
| Sum , product | solve the quadratic for ; use 1s to pad |
| disjoint bit sets () | |
| numbers with all subset sums distinct | powers of 2 |
| Sum of distinct squares | greedy from the largest |
| Prescribed remainders | CRT |
is worth memorising — it appears constantly, and it is the statement that XOR is addition without carries.
The XOR toolbox
| Fact | Use |
|---|---|
| has period 4 in | prefix XOR in |
| pair up ranges to cancel | |
| duplicate to cancel | |
| Any values can be made to XOR to 0 by adding one element | that element is their XOR |
| Consecutive pairs XOR to 1 | build a target XOR from pairs |
The general recipes
- Alternate. High-low interleaving separates values.
- Pair up. Match with so pairs have a constant sum.
- Recurse. Solve or , then extend.
- Handle small separately. Most constructions have 2-3 exceptional cases.
- Use powers of two. They make sums and XORs independent.
- Use a shift or rotation. is a rich family.
- Colour or partition. Split by parity, residue, or a colouring.
- Be greedy from an extreme. Largest first, or most constrained first.
Always verify
Write the construction, then check it with a brute force on — including the exceptional cases. Constructions are easy to get almost right, and “almost” fails on exactly one test.
See also: Small Cases · General · Invariants