Learn · With · Examples
Lottery odds, poker hands, phone lock codes, Olympic podiums, pizza orders — they’re all counting problems in disguise, and they all come down to one question: does order matter? This guide explains permutations and combinations using nothing but real, everyday examples, with interactive scenario galleries and full worked calculations.
Contents
- The difference — a lock code vs. a fruit bowl
- Formal definitions — the nPr and nCr formulas
- Interactive: permutation or combination?
- The factorial foundation
- Interactive: real-life permutations gallery
- Interactive: real-life combinations gallery
- The “does order matter?” test
- Worked example — building a real password system
- Permutations and combinations with repetition
- Pascal’s Triangle connection
- Real-world domains
- Code examples — Python
- Knowledge quiz
Section 01
The Difference — A Lock Code vs. A Fruit Bowl
Imagine two everyday situations. First: you’re setting a 3-digit code on a padlock using digits 1, 2, and 3. The code 1-2-3 is completely different from 3-2-1 — they open different locks (or rather, only the exact sequence you set will open yours). Order matters. This is a permutation.
Second: you’re picking 3 fruits from a bowl to make a smoothie — an apple, a banana, and an orange. It doesn’t matter if you grabbed the apple first or the orange first — you end up with the exact same smoothie ingredients either way. Order doesn’t matter. This is a combination.
💡 The One Question That Decides Everything
Every counting problem in this entire topic reduces to a single question: if I rearrange the same items, do I get something different? Yes → permutation. No → combination. Everything else is just formula mechanics built on top of that one distinction.
Section 02
Formal Definitions — The nPr and nCr Formulas
Both formulas start from the same n items, choosing r of them — they only differ in whether order counts.
🔗 How They’re Related
Notice combinations = permutations ÷ r!. That’s not a coincidence — every unordered group of r items can be arranged in r! different orders. Combinations “collapse” all those orderings into one, because order doesn’t matter. C(n,r) = P(n,r) / r!
Section 03
Interactive: Permutation or Combination?
Click through 5 real scenarios. Try to guess before reading the reasoning — this is the exact judgment call you’ll need to make on every word problem you encounter.
Section 04
The Factorial Foundation
Both formulas are built entirely from factorials, so it’s worth getting comfortable with them first. n! (read “n factorial”) means multiply every whole number from n down to 1.
| n | n! | Real meaning |
|---|---|---|
| 0! | 1 | By definition — there’s exactly 1 way to arrange nothing |
| 1! | 1 | One item — only one arrangement possible |
| 2! | 2 | 2 books on a shelf: AB or BA |
| 3! | 6 | 3 runners crossing the finish line, in order |
| 4! | 24 | 4 people seated around a table |
| 5! | 120 | 5 songs in a playlist order |
| 6! | 720 | 6 books arranged on a shelf |
| 10! | 3,628,800 | 10 runners in a full race ranking |
⚠️ Why 0! = 1
This trips people up constantly. Think of factorial as “number of ways to arrange these items.” With zero items, there’s exactly one way to arrange them: do nothing. An empty arrangement is still one valid arrangement — so 0! = 1, not 0.
Section 05
Interactive: Real-Life Permutations Gallery
Four real scenarios where order matters, each fully calculated.
P(8,3) = 8! / (8−3)! = 8! / 5!
= 8 × 7 × 6
= 336 possible podium outcomes
10 × 10 × 10 × 10
= 10⁴
= 10,000 possible PINs
5! = 5 × 4 × 3 × 2 × 1
= 120 possible lineups
P(26,4) = 26! / (26−4)! = 26! / 22!
= 26 × 25 × 24 × 23
= 358,800 possible passwords
Section 06
Interactive: Real-Life Combinations Gallery
Four real scenarios where order doesn’t matter — only which items get chosen.
C(49,6) = 49! / [6! × 43!]
= (49×48×47×46×45×44) / 720
= 13,983,816 possible combinations
C(10,3) = 10! / [3! × 7!]
= (10×9×8) / (3×2×1)
= 720 / 6 = 120 possible committees
C(8,3) = 8! / [3! × 5!]
= (8×7×6) / (3×2×1)
= 336 / 6 = 56 possible pizzas
C(52,5) = 52! / [5! × 47!]
= (52×51×50×49×48) / 120
= 2,598,960 possible hands
Section 07
The “Does Order Matter?” Test
A reliable 3-step process for any word problem you encounter:
Swap two of your chosen items — does the outcome change?
If choosing Alice-then-Bob gives a genuinely different result than Bob-then-Alice (different roles, different positions), order matters → permutation. If it’s the same outcome either way → combination.
Check for distinct roles or positions
Ranks (1st/2nd/3rd), seats, digit positions, and named roles (president/treasurer) all signal permutation. A “set” or “group” with no internal distinction signals combination.
Check if repetition is allowed
If the same item can be chosen more than once (like PIN digits or dice rolls), you need the “with repetition” formula — covered in Section 9 — regardless of whether order matters.
⚠️ The Most Common Mistake
Students often default to combinations because the formula “feels simpler.” But most everyday scenarios with roles, rankings, sequences, or codes are permutations. Always run the swap test in Step 1 before picking a formula.
Section 08
Worked Example — Building a Real Password System
Let’s combine everything into one realistic problem: a website requires passwords with exactly 2 different letters (no repeats) followed by 3 digits (digits CAN repeat). How many total passwords are possible?
Break it into two independent parts
Part A: choosing 2 different letters in order. Part B: choosing 3 digits, repeats allowed. We’ll solve each separately, then multiply.
Solve Part A — the letters
2 letters, no repeats, order matters (AB ≠ BA as passwords) → this is a permutation. P(26,2) = 26 × 25 = 650 possible letter pairs.
Solve Part B — the digits
3 digits, repeats allowed, order matters → permutation with repetition. 10 × 10 × 10 = 1,000 possible digit sequences.
Apply the multiplication principle
Every letter-pair can be combined with every digit-sequence — so multiply the two results together.
Part B (digits): 10³ = 1,000
Total passwords = 650 × 1,000
= 650,000 possible passwords
🔗 The Multiplication Principle
Whenever a problem splits into independent stages (letters, THEN digits), multiply the number of possibilities at each stage. This single rule — the fundamental counting principle — is what lets you break any complex real-world counting problem into smaller, solvable permutation and combination pieces.
Section 09
Permutations and Combinations with Repetition
The formulas above assume each item can only be chosen once. Real life often allows repeats — here’s how the math changes.
Worked Example — Ice Cream Scoops
An ice cream shop has 5 flavors. You order 3 scoops, and you’re allowed to repeat a flavor (like 2 scoops chocolate + 1 scoop vanilla). Order doesn’t matter — a cup with chocolate-chocolate-vanilla is the same order regardless of which scoop went in first.
C(n + r − 1, r) = C(5 + 3 − 1, 3) = C(7,3)
= 7! / [3! × 4!] = (7×6×5) / 6
= 35 possible ice cream orders
Section 10
Pascal’s Triangle Connection
Every entry in Pascal’s Triangle IS a combination value. Row n, position k gives you exactly C(n,k) — no calculation required, just count and look it up.
Look at row n=6: the entries are C(6,0)=1, C(6,1)=6, C(6,2)=15, C(6,3)=20, and so on. Each number is the sum of the two numbers diagonally above it — which is exactly Pascal’s Rule: C(n,k) = C(n−1,k−1) + C(n−1,k).
💡 Where You’ve Actually Seen This
Pascal’s Triangle is also the coefficients of a binomial expansion — (a+b)⁶ expands using exactly the row-6 numbers: 1, 6, 15, 20, 15, 6, 1. It’s the same combinatorics showing up in algebra, probability, and even genetics (Punnett square ratios follow these same patterns).
Section 11
Real-World Domains
Cryptography
Key space size for a cipher is a permutation calculation — the number of possible keys directly determines how brute-forceable an encryption scheme is.
Genetics
Counting possible DNA sequences, or the number of ways alleles can combine in offspring, relies directly on permutation and combination formulas.
Tournament Brackets
The number of possible ways a single-elimination bracket can play out, or how many unique round-robin schedules exist, is pure combinatorics.
Scheduling
Assigning employees to shifts, or students to exam time slots, is a permutation/combination problem — especially when constraints (no repeats, fixed roles) apply.
Quality Control
Choosing a random sample of r items from a batch of n to inspect for defects is a classic combination — order of inspection doesn’t matter.
Game Design
Loot drop tables, card game deck compositions, and probability balancing in games all rely on combinatorics to calculate fair odds.
Section 12
Code Examples — Python
Using math.perm() and math.comb() (Python 3.8+)
import math # Olympic podium — 3 medals from 8 finalists, order matters print(math.perm(8, 3)) # 336 # Lottery — choose 6 numbers from 49, order doesn't matter print(math.comb(49, 6)) # 13983816 # Password letters — 2 of 26, no repeats, order matters print(math.perm(26, 2)) # 650 # Pizza toppings — choose 3 of 8, order doesn't matter print(math.comb(8, 3)) # 56 # PIN code — permutation WITH repetition (not built into math module) pin_combos = 10 ** 4 print(pin_combos) # 10000 # Ice cream scoops — combination WITH repetition (stars and bars) ice_cream = math.comb(5 + 3 - 1, 3) print(ice_cream) # 35
Generating the actual arrangements with itertools
from itertools import permutations, combinations runners = ['A', 'B', 'C', 'D'] # All ordered podium outcomes (top 3 of 4 runners) podiums = list(permutations(runners, 3)) print(len(podiums)) # 24 = 4P3 print(podiums[:3]) # [('A','B','C'), ('A','B','D'), ('A','C','B'), ...] # All unordered committees (any 3 of 4 people) committees = list(combinations(runners, 3)) print(len(committees)) # 4 = 4C3 print(committees) # [('A','B','C'), ('A','B','D'), ('A','C','D'), ('B','C','D')]
Section 13
Knowledge Quiz
Click a question to expand it, then pick your answer.
