← All posts
November 23, 2026 · 2 min read

Permutations vs combinations: 6 orders on a shelf, 1 set in a bag

Permutations vs combinations with three books: 6 orders on a shelf, 1 set in a bag, and why you divide by the repeats when order doesn't matter.

Permutations vs combinations comes down to one question: does the order matter? If it does, you count arrangements (permutations). If it doesn't, you count sets (combinations), and you get there by counting the arrangements first and dividing by how many times each set repeats. Three books are enough to see all of it.

Three books on a shelf, teal, mustard and blue, with the question: how many orders?

What are the rules?

There are three different books: teal, mustard and blue. On a shelf, the same three books stay on the shelf every time; only their order from left to right changes. Mustard, blue, teal is a different shelf from teal, mustard, blue, even though it holds the same books.

The same three books swapped into a new order: same 3 books, only the order changes

How many orders are there?

Play out every possibility, grouped by which book goes first.

  • Teal first: then mustard, blue, or blue, mustard. 2 orders.
  • Mustard first: then teal, blue, or blue, teal. 2 orders.
  • Blue first: then teal, mustard, or mustard, teal. 2 orders.

Three choices for the first book, and each leaves two ways to finish: 6 orders in all.

All six orders laid out on shelves, two for each first book: teal first, mustard first, blue first, stamped 6 orders

What happens when the order doesn't matter?

Drop the three books in a bag. A bag has no left and right; all it records is which books are inside. Every one of the 6 shelves turns into the same bag, so 6 orders make just 1 set.

The six orders on small shelves, each with an arrow into one bag holding all three books: 6 orders, 1 set

Why do you divide by the repeats?

One bag of all three books is easy to see. Take just two of the three books and the idea shows up properly.

With order, there are 6 ways to put two books on a shelf: each pair of books sits in two orders.

Set (bag) Orders on the shelf
teal + mustard teal, mustard / mustard, teal
teal + blue teal, blue / blue, teal
mustard + blue mustard, blue / blue, mustard

Every set shows up exactly twice, once for each of its orders. So the 6 orders are only 3 sets: 6 divided by 2.

Two books at a time: each pair on the shelf in two orders, divided by 2 into one bag each, 6 orders to 3 sets

That's the whole rule. If order matters, count the orders. If it doesn't, count the orders anyway, then divide by how many orders each set has. For three books in one bag that's 6 divided by 6, which is 1; for two books from three it's 6 divided by 2, which is 3.

Check it with code

The script lists every order, forgets the order with a frozenset, and counts what's left. It also shuffles the three books 600,000 times to check that every order turns up about one time in six:

from collections import Counter
from itertools import permutations
import random

BOOKS = ['teal', 'mustard', 'blue']

orders = list(permutations(BOOKS))             # every left-to-right order
print('orders of 3 books:', len(orders))
print('sets (bags) they make:', len({frozenset(o) for o in orders}))

picks = list(permutations(BOOKS, 2))           # take two, order matters
sets = Counter(frozenset(p) for p in picks)    # forget the order
print('ordered picks of 2:', len(picks))
print('sets of 2:', len(sets), '- each seen', set(sets.values()), 'times')
print('6 orders / 2 repeats =', len(picks) // 2)

rng = random.Random(10)
shelves = Counter(tuple(rng.sample(BOOKS, 3)) for _ in range(600_000))
print('simulated shuffles: orders seen', len(shelves), 'of 6, each',
      f'{min(shelves.values()) / 600_000:.3f}', 'to', f'{max(shelves.values()) / 600_000:.3f}', '(exact 1/6 = 0.167)')

Output:

orders of 3 books: 6
sets (bags) they make: 1
ordered picks of 2: 6
sets of 2: 3 - each seen {2} times
6 orders / 2 repeats = 3
simulated shuffles: orders seen 6 of 6, each 0.166 to 0.168 (exact 1/6 = 0.167)

Try it

Five books, pick two: how many sets? Count the orders first (how many books can go first, and how many are left for second), then divide by the repeats.