In short
When objects must always be together, bundle them into a single block, permute the blocks, then permute within each block. When objects must never be together, count all arrangements and subtract the ones where they are together (complementary counting). When the relative position of certain objects is fixed, divide by the number of internal orderings. The rank of a word is its position in the dictionary ordering of all permutations of its letters — found by counting how many words come before it, one position at a time.
Five friends — Aarav, Bhumi, Chirag, Diya, and Eshan — line up for a photograph. There are 5! = 120 ways to arrange them. But the photographer has a request: Aarav and Bhumi, who are siblings, must stand next to each other. How does this constraint change the count?
Your first instinct might be to list cases, but that gets unmanageable quickly. A cleaner method: treat Aarav and Bhumi as a single block [AB]. Now there are 4 objects to arrange — [AB], Chirag, Diya, Eshan — giving 4! = 24 arrangements. But inside the block, Aarav can be on the left or the right, so each block arrangement comes in 2 internal orders. Total: 4! \times 2! = 24 \times 2 = 48.
This is the block method, and it is the first of four techniques covered here: objects always together, objects never together, relative positions fixed, and finding the rank of a word in dictionary order.
Objects always together (the block method)
The block method turns an "always together" constraint into an unrestricted permutation of fewer objects.
The recipe:
- Bundle the constrained objects into a single block.
- Count the arrangements of the blocks (and remaining objects) as if each block were a single item.
- Multiply by the internal arrangements within each block.
What if more than two objects must be together? The same idea works. If 3 specific friends must stand together, bundle them into one block. You now have n - 3 + 1 = n - 2 objects to arrange, and the block's internal arrangements multiply by 3!.
What if multiple groups must each be together? Bundle each group separately. If k_1 objects form one block and k_2 objects form another, you have n - k_1 - k_2 + 2 objects to arrange, and you multiply by k_1! \times k_2! for the internal arrangements.
The block method in circular arrangements. The same principle works at a round table. If n people sit in a circle and k of them must sit together, form a block of k people. There are now n - k + 1 objects around the circle, giving (n-k)! circular arrangements (fixing one reference point). Multiply by k! for the block's internal order: total = (n-k)! \times k!.
Objects never together (complementary counting)
Suppose the photographer now says: Aarav and Bhumi must not stand next to each other. Directly counting valid arrangements is tricky — you would need to handle where Aarav stands, then ensure Bhumi avoids the adjacent spots, and the casework branches quickly.
The cleaner route: complementary counting. Count the total arrangements without any restriction, then subtract the "bad" ones (where Aarav and Bhumi are together).
Why complementary counting works. The "together" arrangements and the "never together" arrangements are disjoint and exhaustive — every arrangement falls into exactly one of the two groups. By the addition principle, their counts sum to the total. So the "never together" count is the total minus the "together" count.
A slightly harder version. In a row of 7 people, persons P, Q, and R must not all three be adjacent (but any two of them may be adjacent). Direct counting is complex. Complementary counting: 7! - (\text{all three together}) = 5040 - (5! \times 3!) = 5040 - 720 = 4320.
General pattern. Whenever a restriction says "must not" or "never," think: can I count the complementary case ("must" or "always") and subtract? Often the "always" version is a block-method problem, which is easier.
Relative position fixed
Seven books are placed on a shelf: 3 mathematics books (M₁, M₂, M₃) and 4 science books (S₁, S₂, S₃, S₄). The total arrangements are 7! = 5{,}040. But now a constraint: the 3 mathematics books must maintain their mutual order — M₁ must be to the left of M₂, which must be to the left of M₃ — though they need not be adjacent.
The 3 mathematics books can appear in 3! = 6 possible mutual orderings among themselves. Only one of these 6 orderings (M₁ before M₂ before M₃) is valid. By symmetry, exactly 1/6 of all arrangements satisfy this constraint:
Relative position fixed
If n objects are arranged in a row and k specific objects must maintain a particular mutual ordering, the number of valid arrangements is:
Why it works. Consider all n! arrangements. The k constrained objects occupy k positions, and among those k positions, they can appear in k! different orderings. By symmetry (each ordering is equally likely in a random arrangement), exactly n!/k! of the arrangements have the desired ordering.
This technique applies whenever you fix the relative order of some objects without requiring them to be adjacent. If they must also be adjacent, you would use the block method instead (with only 1 valid internal arrangement, the block gives (n - k + 1)! \times 1).
Rank of a word
Take the letters of the word JUMBLE and arrange them in dictionary (alphabetical) order. The sorted letters are: B, E, J, L, M, U. Every arrangement of these 6 distinct letters is a 6-letter "word," and there are 6! = 720 such words. The rank of a word is its position when all 720 words are listed in alphabetical order.
What is the rank of JUMBLE?
The method: count how many words come before JUMBLE in dictionary order, then add 1.
Position 1: J. How many words start with a letter before J? The letters before J in alphabetical order are B and E — that is 2 letters. Each of them can be followed by any arrangement of the remaining 5 letters: 2 \times 5! = 2 \times 120 = 240 words.
Position 2: U (with J fixed in position 1). Remaining letters after J is used: B, E, L, M, U. How many words start with J and have a second letter before U? The letters before U among {B, E, L, M, U} are B, E, L, M — that is 4 letters. Each gives 4! arrangements of the remaining 4 letters: 4 \times 4! = 4 \times 24 = 96 words.
Position 3: M (with JU fixed). Remaining letters: B, E, L, M. Before M: B, E, L — 3 letters. Each gives 3! arrangements: 3 \times 3! = 3 \times 6 = 18 words.
Position 4: B (with JUM fixed). Remaining letters: B, E, L. Before B: none — 0 letters. Contribution: 0.
Position 5: L (with JUMB fixed). Remaining letters: E, L. Before L: E — 1 letter. Each gives 1! = 1 arrangement: 1 \times 1! = 1 word.
Position 6: E (with JUMBL fixed). Only E remains. No letter comes before E. Contribution: 0.
Total words before JUMBLE: 240 + 96 + 18 + 0 + 1 + 0 = 355.
Rank of JUMBLE = 355 + 1 = 356.
The algorithm for rank. For a word with n distinct letters:
- At each position i (from left to right), count the number of remaining unused letters that are alphabetically smaller than the letter at position i. Call this c_i.
- Multiply c_i by (n - i)! — the number of arrangements of the remaining positions.
- Sum all contributions: \sum c_i \times (n-i)!.
- The rank is this sum plus 1 (because the word itself is the next one after all the words counted).
When the word has repeated letters, the algorithm adjusts: at each position, instead of multiplying by (n-i)!, multiply by the number of distinct arrangements of the remaining letters (using the "not all different" formula).
Two worked examples
Example 1: In how many ways can the letters of INDIA be arranged so that the two I's are never adjacent?
Step 1. Identify letter frequencies and total arrangements.
INDIA has 5 letters: I (2), N (1), D (1), A (1). The total distinct arrangements (from the not-all-different formula) are:
Why: the two I's are identical, so dividing by 2! removes the overcounting. The other letters appear once each, contributing 1! each (no effect).
Step 2. Count the arrangements where the two I's are adjacent (the "bad" cases).
Treat the two I's as a single block [II]. Now there are 4 objects: [II], N, D, A. These are all distinct (the block is a single entity), so the arrangements are 4! = 24. The block has only 1 internal arrangement (since both letters inside are I — swapping identical letters changes nothing).
Why: the block [II] behaves like a single letter. Unlike a block of two different letters (which would have 2! internal orders), two identical I's have just 1 internal arrangement.
Step 3. Apply complementary counting.
Why: every arrangement either has the two I's adjacent or has them separated. These two sets are disjoint and exhaustive, so subtracting gives the count of separated arrangements.
Step 4. Sanity check.
The "never adjacent" count (36) is 60\% of the total (60). For 5 positions, there are \binom{4}{1} = 4 pairs of adjacent positions (positions 1-2, 2-3, 3-4, 4-5) and \binom{5}{2} = 10 ways to place 2 items in 5 positions. The fraction of adjacent placements is 4/10 = 40\%, so the non-adjacent fraction should be 60\%. This matches 36/60 = 0.6.
Result. 36 arrangements of INDIA with the two I's never adjacent.
The complementary counting approach avoids the difficulty of directly placing two I's in non-adjacent positions (which would require case analysis over which positions they occupy). The "always together" count was easy via the block method, and one subtraction gave the answer.
Example 2: Find the rank of the word CRAFT in dictionary order among all arrangements of its letters.
The letters of CRAFT are A, C, F, R, T (sorted alphabetically). All 5 letters are distinct, so there are 5! = 120 words in the dictionary listing.
Step 1. Position 1 is C. Letters before C among \{A, C, F, R, T\}: just A (1 letter). Contribution: 1 \times 4! = 1 \times 24 = 24.
Why: every word starting with A comes before every word starting with C. There are 4! words starting with A (the remaining 4 letters can go in any order).
Step 2. Position 2 is R (with C fixed). Remaining letters: \{A, F, R, T\}. Letters before R: A, F (2 letters). Contribution: 2 \times 3! = 2 \times 6 = 12.
Why: among words starting with C, those whose second letter is A or F come before those with second letter R. Each such second letter leads to 3! arrangements of the remaining 3 positions.
Step 3. Position 3 is A (with CR fixed). Remaining letters: \{A, F, T\}. Letters before A: none (0 letters). Contribution: 0 \times 2! = 0.
Why: A is the smallest remaining letter, so no words with CR followed by something before A exist.
Step 4. Position 4 is F (with CRA fixed). Remaining letters: \{F, T\}. Letters before F: none (0 letters). Contribution: 0 \times 1! = 0.
Why: F is the smaller of the two remaining letters.
Step 5. Position 5 is T (with CRAF fixed). Only T remains. Contribution: 0.
Total words before CRAFT: 24 + 12 + 0 + 0 + 0 = 36.
Rank of CRAFT = 36 + 1 = 37.
Result. CRAFT is the 37th word in the dictionary listing of all arrangements of its letters.
You can verify: the very first word (rank 1) in the dictionary is ACFRT, and the last (rank 120) is TRFCA. CRAFT sits at position 37 — roughly a third of the way through, which makes sense since C is the second of five sorted letters.
Common confusions
-
"For 'never together,' subtract 2 from n instead of using the block method." There is no such shortcut. The correct approach is: total arrangements minus the "always together" count (computed via the block method). The block method bundles the constrained objects, reducing the number of items to permute — the reduction depends on how many objects are bundled, not on a fixed rule of "subtract 2."
-
"Fixing relative order means the objects must be adjacent." It does not. "M₁ must be to the left of M₂" allows any number of objects between them. If they must also be adjacent (and in order), that is a block with a single valid internal arrangement.
-
"The rank formula works only for distinct letters." The algorithm can be extended to repeated letters, but the factorial at each step must be replaced by the multinomial count for the remaining letters. For distinct letters, the formula is simpler because each remaining arrangement count is a plain factorial.
-
"Complementary counting always involves subtraction." It does — that is the definition. You compute total minus the complement. The power is that the complement is often easier to count than the desired set directly.
-
"The block method does not work for circular arrangements." It does. Form the block, count circular arrangements of the reduced set (using (m-1)! where m is the number of objects after blocking), then multiply by the block's internal arrangements.
Going deeper
If you can handle "always together," "never together," relative order, and rank-of-a-word problems, you are ready for combinations and combinations with restrictions. The rest of this section explores more advanced restriction techniques and connects to the language of set complements.
The gap method (objects never together — an alternative)
Instead of complementary counting, you can directly place objects into gaps. Arrange the unrestricted objects first, then place the restricted objects in the gaps between them.
For example: arrange 5 people so that A and B are never adjacent. First arrange the other 3 (C, D, E) in a row: 3! = 6 ways. This creates 4 gaps (including the two ends):
Now place A and B in 2 of these 4 gaps (one person per gap, since if they shared a gap they would be adjacent). The number of ways to choose 2 gaps from 4 and assign A and B to them (order matters) is {}^4P_2 = 4 \times 3 = 12.
Total: 3! \times {}^4P_2 = 6 \times 12 = 72.
This matches the complementary counting result (120 - 48 = 72), confirming both methods. The gap method is especially useful when more than two objects must all be separated from each other.
Rank with repeated letters
Suppose you want the rank of AABA among all arrangements of \{A, A, A, B\}. The distinct arrangements number 4!/(3!\cdot 1!) = 4, and listing them in order gives: AAAB (rank 1), AABA (rank 2), ABAA (rank 3), BAAA (rank 4).
The algorithm: at position 1, the letter is A. Are there letters before A? No. Contribution: 0. At position 2, the letter is A again. Before A? No. Contribution: 0. At position 3, the letter is B. Remaining letters are \{A, B\}. Before B: A (1 letter). If A were placed here, the remaining letters are \{B\} giving 1!/1! = 1 arrangement. Contribution: 1. At position 4: only A remains. Contribution: 0.
Total before AABA: 0 + 0 + 1 + 0 = 1. Rank = 1 + 1 = 2. Correct.
The key adjustment: at each position, when letters repeat, you compute the number of distinct arrangements of the remaining letters (using the multinomial formula), not a plain factorial. This makes the computation slightly more involved but follows the same structure.
Derangements revisited
A derangement is a permutation where every object is in a "wrong" position — no object occupies its original place. The derangement count D_n = n! \sum_{k=0}^{n} (-1)^k / k! is a restriction problem at heart: you have n constraints (object i cannot be in position i), and the inclusion-exclusion principle computes the count of arrangements satisfying all n constraints simultaneously. The connection to this article is that "never in position i" is a position-based restriction, just like the "never adjacent" problems above — but with n simultaneous constraints instead of one.
Where this leads next
- Combinations — Basics — when order does not matter, the counting changes from permutations to combinations.
- Combinations with Restrictions — the selection counterpart of these restriction techniques, applied to unordered selections.
- Permutations — Special Cases — circular permutations, necklaces, and identical objects: the other set of modifications to the basic formula.
- Permutations — Basics — review the {}^nP_r formula and its derivation.
- Fundamental Principle of Counting — the addition and multiplication principles that power every technique here.