skip to content

questions

4

Permutations vs combinations: which counts a top-3 podium from 30 entrants?

level: juniorimportance: must knowfreq 62%

answer

  1. ask whether swapping two picks matters
  2. podium order versus shortlist membership
  3. one count divides the other exactly
  4. the divisor is k factorial
  5. 24,360 is six times 4,060

basics

~20 s

Permutations count arrangements where order matters; combinations count selections where it does not. A ranked top-3 podium from 30 entrants gives 30 x 29 x 28 = 24,360 outcomes; an unordered shortlist of three gives only 4,060.

solid answer

~40 s

Ask one question: if I swap two of the chosen items, is that a different outcome? If yes you are counting permutations, if no you are counting combinations. A podium has distinct first, second and third places, so it is `P(30,3) = 30 * 29 * 28 = 24,360` — thirty choices for the top slot, twenty-nine left for the second, twenty-eight for the third. An unordered shortlist of three finalists collapses every group of `3! = 6` orderings of the same trio into one outcome, so it is `C(30,3) = 24,360 / 6 = 4,060`. The two counts always differ by exactly `k!`, which is why using the permutation count for a selection problem overcounts by a factor that grows very fast in `k`.

go deeper

for a junior

Be ready to state the swap test in one sentence and apply it to a ranked podium versus an unordered shortlist. Building 30 x 29 x 28 slot by slot, then dividing by 3! for the unordered version, is enough here.

for a middle

Explain where the k! divisor comes from — every unordered trio corresponds to exactly 3! ordered lineups — rather than quoting a memorised formula. Expect a follow-up on what changes when an item may repeat.

for a senior

Show that you pin down both assumptions before reaching for a formula: does order matter, and may an item be reused. Most real miscounts trace back to an unstated assumption rather than to bad arithmetic.

for a principal

Own the framing. Whether a problem counts arrangements or selections decides the size of the space a team is about to search, and a factor of k! is often what decides whether an exhaustive approach is viable at all.

## The one test that decides it Every problem in this family reduces to a single question: **if I swap two of the chosen items, do I have a different outcome?** If yes, the arrangement itself is part of the answer and you are counting *permutations*. If no — the outcome is nothing more than *which* items were chosen — you are counting *combinations*. A *permutation* of size k drawn from n distinct items is an ordered sequence of k of them, no item used twice. A *combination* of size k is an unordered set of k of them. Same raw material, different notion of "same outcome". ## Working a concrete count Thirty entrants; the leaderboard awards a distinct first, second and third place. Fill the slots one at a time. Any of the 30 can take first place. Whoever takes it is gone, so 29 remain for second, and 28 for third. Multiply the independent slot choices: `P(30,3) = 30 x 29 x 28 = 24,360` Now change the question: pick three finalists, no ranking. Take the 24,360 ordered lineups and group them by *which trio* they contain. Each trio of three distinct entrants appears in exactly `3! = 6` different orders, so every group has exactly six members. The number of groups is therefore `C(30,3) = 24,360 / 6 = 4,060` That grouping argument — a clean many-to-one correspondence with a constant group size — is the entire reason the `k!` divisor appears. It is worth being able to say out loud, because it generalises: whenever you have counted ordered outcomes but the order is not meaningful, divide by the number of orderings of each outcome. ## The formulas, and where they come from - `P(n,k) = n x (n-1) x ... x (n-k+1) = n! / (n-k)!` — the falling product of k factors, written as a ratio of factorials. - `C(n,k) = P(n,k) / k! = n! / (k! (n-k)!)`. The factorial forms are the compact way to *write* these counts, not the sensible way to *evaluate* them: for the podium, `30!` is a 33-digit number even though the answer is 24,360. When you actually compute, use the falling product, or the running multiply-and-divide form of the binomial coefficient. ## Two assumptions people silently conflate Order-matters is only one of the two switches. The other is whether an item may be reused. | | order matters | order ignored | |---|---|---| | **each item used at most once** | `P(n,k) = n!/(n-k)!` — 24,360 | `C(n,k) = n!/(k!(n-k)!)` — 4,060 | | **items may repeat** | `n^k` — 27,000 | a separate counting family, not covered here | Most real miscounts are not arithmetic errors; they are an unstated assumption. "Three podium places from thirty entrants" is 24,360 only if one entrant cannot occupy two places. If the scenario were three awards that the same entrant *could* sweep, the count is `30^3 = 27,000`. Say both assumptions aloud before you write a formula. ## The symmetry worth knowing `C(n,k) = C(n, n-k)`. Choosing which 3 entrants make the shortlist is the same act as choosing which 27 do not, so the counts must be equal: `C(30,3) = C(30,27) = 4,060`. This is not a curiosity — it is the practical trick that lets you always compute with the smaller of k and n-k, keeping loop lengths and intermediate values small. ## Why an interviewer bothers asking Because the distinction sets the *size of a space someone is about to search*. Selections and arrangements of the same items are not close in magnitude; the ratio between them is `k!`, and `k!` outruns any constant factor an engineer can win back by optimising a loop. Getting the count right on paper decides whether an exhaustive approach is even on the table, before a line of code exists. ## Wrong turns to avoid - Reaching for `n!` when only k of the n items are chosen. `30!` counts orderings of *all thirty* entrants, roughly 2.65 x 10^32 — a different question entirely. - Assuming combinations are larger than permutations. For `k >= 2` the combination count is strictly smaller; the two coincide only when `k` is 0 or 1. - Treating "distinct items" and "order matters" as the same switch. They are independent, and each has its own formula.

  • How do the two counts relate to each other formulaically?
    `P(n,k) = n!/(n-k)!` and `C(n,k) = P(n,k)/k! = n!/(k!(n-k)!)`. Every unordered selection of k items corresponds to exactly `k!` ordered arrangements of those same items, so dividing the permutation count by `k!` collapses the duplicates. The ratio between the two counts is `k!` and does not depend on n.
  • If the same entrant may take more than one podium place, does the count change?
    Yes. Allowing repeats removes the shrinking pool, so instead of `30 x 29 x 28` you get `30 x 30 x 30 = 27,000`. Whether items may repeat is a separate assumption from whether order matters; pin both down before choosing a formula, because the two switches give four different counting families.
  • Why is C(n,k) equal to C(n, n-k)?
    Choosing which 3 of 30 entrants make the shortlist is the same act as choosing which 27 are left out, so the two counts are the same number: `C(30,3) = C(30,27) = 4,060`. Practically it means you can always compute with the smaller of k and n-k, which keeps the loop short and the intermediate values small.

A podium photograph and a guest list can hold the same three people: rearranging the photograph gives a new picture, rearranging the guest list gives the same list.

saying these in an interview costs you the question

  • Says order never matters when picking winners
  • Uses n! to count a choice of k items from n
  • Claims C(n,k) is larger than P(n,k)
  • Conflates distinct picks with picks allowing repeats
  • Thinks the two counts differ by a factor of n

context

open as a page

Why compute nCr with the multiplicative formula instead of n!/(k!(n-k)!)?

level: middleimportance: should knowfreq 46%

basics

~20 s

The factorials overflow long before the answer does. Choosing 6 winners from 30 entrants is only 593,775, yet 21! already exceeds a 64-bit signed integer. The multiplicative form interleaves multiplying and dividing, keeping every intermediate value near the answer's size.

open as a page

Is brute-forcing every visit order of 12 delivery stops viable, and how do you know?

level: seniorimportance: should knowfreq 50%

basics

~20 s

Barely, and only offline: 12! = 479,001,600 orderings is a few hundred million evaluations, roughly seconds to minutes on one core. But 13! is 6.2 billion and 15! is 1.3 trillion, so the approach dies within three more stops.

open as a page

Why does Pascal's rule C(n,k) = C(n-1,k-1) + C(n-1,k) hold combinatorially?

level: middleimportance: nice to knowfreq 34%

basics

~20 s

Fix one element and split every selection by whether it is chosen: those including it pick k-1 more from the remaining n-1, those excluding it pick all k from those n-1. The cases are disjoint and exhaustive, so the counts add.

open as a page