Counting Strategies: Casework, Complementary & Overcounting

Study Sheet

Counting Strategies: Casework, Complementary & Overcounting

Competition counting & probability, Unit 2

Casework Counting

Concept
The idea

When a counting problem has no single clean formula, split it into cases that are mutually exclusive (no outcome lands in two cases) and exhaustive (every outcome lands in some case). Count each case separately, then add.

Total=(Case 1)+(Case 2)++(Case k).\text{Total} = (\text{Case 1}) + (\text{Case 2}) + \cdots + (\text{Case }k).

Choose your cases along the feature that is causing the trouble: the value of the largest digit, whether a coin came up heads, how many objects of a certain type were chosen, and so on. Good cases make each sub-count easy.

Example
Worked example: sums on two dice

How many ordered pairs (a,b)(a,b) with a,b{1,,6}a,b\in\{1,\dots,6\} have a+ba+b a multiple of 33?

Case a+b=3a+b=3: (1,2),(2,1)(1,2),(2,1)22 ways. Case a+b=6a+b=6: (1,5),(2,4),(3,3),(4,2),(5,1)(1,5),(2,4),(3,3),(4,2),(5,1)55 ways. Case a+b=9a+b=9: (3,6),(4,5),(5,4),(6,3)(3,6),(4,5),(5,4),(6,3)44 ways. Case a+b=12a+b=12: (6,6)(6,6)11 way. These cases are disjoint and cover all multiples of 33 between 22 and 1212, so the total is 2+5+4+1=122+5+4+1=\boxed{12}.

Example
Worked example: three-digit numbers with a fixed digit sum

How many three-digit numbers have digits summing to 55? Write the number as abc\overline{abc} with a1a\ge 1. Case on the hundreds digit aa: for each a{1,2,3,4,5}a\in\{1,2,3,4,5\} the tens and units must sum to 5a5-a, giving (5a)+1=6a(5-a)+1=6-a ordered choices. Summing, 5+4+3+2+1=155+4+3+2+1=\boxed{15} numbers.

Tip

Pitfall: cases must not overlap. If an outcome could be counted in two cases, you will double count. Before adding, ask: “Could a single outcome satisfy two of my case descriptions?” If yes, redefine the cases (e.g. “exactly kk” instead of “at least kk”).

Complementary Counting

Concept
The idea

Sometimes counting what you don't want is far easier than counting what you do. If there are NN total outcomes and BB “bad” outcomes, then the number of “good” outcomes is

Good=NBad.\text{Good} = N - \text{Bad}.

This shines when the good outcomes fracture into many messy cases but the bad ones form a tidy family (often a single case).

Example
Worked example: at least one repeated digit

How many three-digit numbers (100100 to 999999) have at least one repeated digit? Total three-digit numbers: 900900. The complement is “all digits distinct”: the hundreds digit has 99 choices (11--99), the tens digit 99 choices (any but the hundreds), the units 88 choices, giving 998=6489\cdot 9\cdot 8=648. Therefore the answer is 900648=252900-648=\boxed{252}.

Tip

Tip: the complement trick pairs perfectly with the phrase “at least one.” The opposite of “at least one” is “none,” which is usually one clean product. See the final section.

Constructive Counting

Concept
The idea

Build a valid configuration one decision at a time, and multiply the number of choices at each step (the multiplication principle). The art is choosing an order of decisions so that the number of options at each step does not depend on the earlier choices in a way you cannot track. Make the most constrained decision first.

Example
Worked example: seating with a restriction

Five people sit in a row of five chairs, but Alice and Bob refuse to sit in the two end chairs. Build the seating: first place the three “unrestricted” people (call them the others). Actually, seat the restricted pair first, since they are the bottleneck. The two end chairs must be filled by 33 non-restricted people: choose an ordered pair for the two ends in 32=63\cdot 2=6 ways. The remaining 33 chairs take the remaining 33 people in 3!=63!=6 ways. Total 66=366\cdot 6=\boxed{36}.

Example
Worked example: strings with no two adjacent A's

How many length-44 strings over {A,B}\{A,B\} have no two adjacent AA's? Build left to right and case on the number of AA's. Equivalently, place the AA's in gaps around the BB's: with kk BB's there are k+1k+1 gaps and we choose positions for the AA's. For 0,1,20,1,2 A's we get (50)+(41)+(32)=1+4+3=8\binom{5}{0}+\binom{4}{1}+\binom{3}{2}=1+4+3=\boxed{8}.

Tip

Pitfall: the multiplication principle needs the count of options at each step to be constant, even if the specific options change. If step 3 sometimes offers 22 choices and sometimes 33 depending on step 1, split into cases first, then multiply within each case.

Overcounting and Correcting

Concept
The idea

Often the easiest count treats some outcomes as different when they should be the same. If every final object is produced the same number of times dd by your over-count MM, then

Answer=Md.\text{Answer} = \frac{M}{d}.

The classic example: arranging nn distinct objects in a circle. Linear arrangements give n!n!, but each circular arrangement appears nn times (one per rotation), so the count is n!/n=(n1)!n!/n=(n-1)!.

Example
Worked example: a necklace

How many distinct necklaces use 55 different colored beads if rotations and reflections are considered the same? Line them up: 5!=1205!=120 arrangements. Each necklace can be rotated 55 ways and flipped 22 ways, so it is counted 52=105\cdot 2=10 times. Answer: 120/10=12120/10=\boxed{12}.

Example
Worked example: choosing a committee counted twice

A club counts committees of 22 from 66 people by “pick a first member (66 ways), pick a second (55 ways)” getting 3030. But {X,Y}\{X,Y\} and {Y,X}\{Y,X\} are the same committee, counted d=2d=2 times. The true count is 30/2=15=(62)30/2=15=\binom{6}{2}, showing (nk)=n!/(nk)!k!\binom{n}{k}=\dfrac{n!/(n-k)!}{k!} is exactly correcting for the k!k! orderings.

Tip

Pitfall: division only works when every object is overcounted the same number of times. If some beads repeat, or a symmetric arrangement is fixed by a rotation, the copies are not all distinct and simple division fails — you need Burnside-style counting (final section).

Bijections & Correspondences

Concept
The idea

To count a hard set AA, find a bijection (a one-to-one, onto pairing) with an easier set BB; then A=B|A|=|B|. A bijection guarantees “no misses, no doubles.” Two famous correspondences:

  • 1pt
  • Subsets \leftrightarrow binary strings: subsets of an nn-set correspond to length-nn strings of 0/1, so there are 2n2^n subsets.
  • Stars and bars: the number of ways to write nn as an ordered sum of kk nonnegative integers equals (n+k1k1)\binom{n+k-1}{k-1}, by pairing each solution with an arrangement of nn stars and k1k-1 bars.
Example
Worked example: stars and bars

How many solutions in nonnegative integers does x1+x2+x3=7x_1+x_2+x_3=7 have? Represent a solution as 77 stars split by 22 bars, e.g. \star\star|\star\star\star|\star\star. Each arrangement of 77 stars and 22 bars gives exactly one solution, so the count is (7+22)=(92)=36\binom{7+2}{2}=\binom{9}{2}=\boxed{36}.

Example
Worked example: lattice paths

How many shortest grid paths go from (0,0)(0,0) to (4,3)(4,3) moving only right/up? Each path is a sequence of 44 R's and 33 U's — a bijection with strings, so (73)=35\binom{7}{3}=\boxed{35}.

Tip

Tip: to prove your map is a bijection, describe the inverse: given an object in BB, recover exactly one object in AA. If you can undo the map uniquely, it is a bijection.

“At Least One” via the Complement

Concept
The idea

The event “at least one” is the complement of “none.” In counting,

#(at least one X)=(total)#(no X),\#(\text{at least one }X) = (\text{total}) - \#(\text{no }X),

and in probability, P(at least one)=1P(none)P(\text{at least one})=1-P(\text{none}). Because “none” usually means every trial avoids XX independently, its count/probability is a single product.

Example
Worked example: at least one six

Roll a fair die 44 times. Probability of at least one six? “No six” on all four rolls has probability (56)4=6251296\left(\tfrac{5}{6}\right)^4=\tfrac{625}{1296}. So P(at least one six)=16251296=6711296P(\text{at least one six})=1-\tfrac{625}{1296}=\boxed{\tfrac{671}{1296}}.

Tip

Tip: watch for the words at least, at most, some, none. These almost always signal complementary counting. “At least one” \to subtract “none”; “at most one” \to subtract “two or more.”

Going Deeper: Combining Strategies

Concept
Layering techniques

Contest problems rarely use one idea in isolation. Common combinations:

  • 2pt
  • Casework ++ complementary: split off the easy-to-count bad outcomes with cases, subtract from the total. E.g. “at least two of a kind” == total - (all distinct).
  • Constructive ++ overcounting: build with the multiplication principle, then divide out an ordering or symmetry you introduced (this is exactly how (nk)\binom{n}{k} arises).
  • Casework inside a bijection: map to an easier set, then do casework there.
Concept
Correcting for symmetry: a Burnside flavor

When simple division fails because some arrangements are fixed by a symmetry, use the Burnside idea: the number of distinct arrangements equals the average number of arrangements left unchanged by each symmetry:

#(distinct)=1GgGFix(g),\#(\text{distinct}) = \frac{1}{|G|}\sum_{g\in G}\text{Fix}(g),

where GG is the group of symmetries (e.g. the nn rotations of a circle) and Fix(g)\text{Fix}(g) counts colorings unchanged by gg. When no nontrivial symmetry fixes any coloring, every Fix(g)=0\text{Fix}(g)=0 except the identity, and Burnside collapses to the plain division M/GM/|G|.

Example
Worked example: Burnside on a bracelet

Color the 33 beads of a triangular bracelet with 22 colors, rotations only (GG has 33 elements: rotate by 0,1,20,1,2). Identity fixes all 23=82^3=8 colorings; each nontrivial rotation fixes only the 22 monochromatic colorings. By Burnside, 13(8+2+2)=123=4\tfrac{1}{3}(8+2+2)=\tfrac{12}{3}=\boxed{4} distinct bracelets.

Tip

Big picture: every strategy here answers the same question — “how do I count each valid outcome exactly once?” Casework partitions the outcomes; complementary counting flips to the easier side; constructive counting sequences the decisions; overcounting/Burnside repairs double counts; bijections transport the problem somewhere friendlier. When stuck, ask three questions: Is the opposite easier to count? Can I break this into clean cases? Am I counting anything more than once?

Burnside's Lemma (Orbit-Counting Theorem)

Concept
The statement

Let a finite group GG of symmetries act on a set XX of configurations (colorings, labelings, …). Two configurations are “the same” when one can be carried to the other by some gGg\in G; the resulting equivalence classes are called orbits. The number of distinct configurations is the number of orbits, and

#(orbits)  =  1GgGFix(g),\#(\text{orbits}) \;=\; \frac{1}{|G|}\sum_{g\in G}\bigl|\mathrm{Fix}(g)\bigr|,

where Fix(g)={xX:gx=x}\mathrm{Fix}(g)=\{x\in X : g\cdot x = x\} is the set of configurations left unchanged by gg. In words: the number of distinct objects equals the average number of colorings fixed by a symmetry. This is the rigorous repair for the “divide by symmetry” shortcut, and it never overcounts even when some configurations have extra symmetry.

Concept
The workhorse formula for colorings

When gg permutes the nn “slots” (beads, faces, cells) and you may color each slot freely with cc colors, a coloring is fixed by gg iff every slot in a cycle of gg receives the same color. Hence

Fix(g)  =  ccyc(g),\bigl|\mathrm{Fix}(g)\bigr| \;=\; c^{\,\mathrm{cyc}(g)},

where cyc(g)\mathrm{cyc}(g) is the number of disjoint cycles of gg (fixed points count as 11-cycles). So the whole problem reduces to a cycle census of the group.

Example
Worked example: two-color bracelets of 66 beads

Count the distinct bracelets of 66 beads, each black or white, where rotations and reflections are considered the same. The symmetry group is the dihedral group D6D_6 with G=12|G|=12. Take a cycle census, using Fix(g)=2cyc(g)\bigl|\mathrm{Fix}(g)\bigr|=2^{\mathrm{cyc}(g)}.

Rotations by kk positions have gcd(k,6)\gcd(k,6) cycles:

k012345cyc6123212cyc6424842sum =84.\begin{array}{c|cccccc} k & 0 & 1 & 2 & 3 & 4 & 5\\\hline \mathrm{cyc} & 6 & 1 & 2 & 3 & 2 & 1\\ 2^{\mathrm{cyc}} & 64 & 2 & 4 & 8 & 4 & 2 \end{array} \qquad\text{sum }=84.

Reflections (six of them, since nn is even): 33 axes pass through two opposite beads (22 fixed beads +2+2 swaps =4=4 cycles 24=16\Rightarrow 2^4=16 each), and 33 axes pass through opposite edges (33 swaps =3=3 cycles 23=8\Rightarrow 2^3=8 each). Reflection sum =3(16)+3(8)=48+24=72=3(16)+3(8)=48+24=72. Therefore

#(bracelets)=84+7212=15612=13.\#(\text{bracelets}) = \frac{84+72}{12} = \frac{156}{12} = \boxed{13}.

(Rotations alone would give 84/6=1484/6=14 necklaces; folding in reflections identifies one mirror pair, leaving 1313.)

Example
Worked example: coloring the faces of a cube with 33 colors

How many distinct ways can the 66 faces of a cube be painted using 33 available colors, where two paintings are the same if a rotation of the cube carries one to the other? The rotation group has G=24|G|=24. Census of how each rotation type permutes the 66 faces:

Averaging over the group,

1729+627+381+89+62724=729+162+243+72+16224=136824=57.\frac{1\cdot 729 + 6\cdot 27 + 3\cdot 81 + 8\cdot 9 + 6\cdot 27}{24} = \frac{729+162+243+72+162}{24} = \frac{1368}{24} = \boxed{57}.

The same recipe with cc colors gives 124(c6+3c4+12c3+8c2)\tfrac{1}{24}(c^6+3c^4+12c^3+8c^2) colorings.

Tip

Method: (1) identify the symmetry group GG and its size; (2) sort the elements into a few types (identity, rotations by angle, reflections through this-or-that axis); (3) for each type find cyc(g)\mathrm{cyc}(g) and multiply ccyc(g)c^{\mathrm{cyc}(g)} by how many elements have that type; (4) add and divide by G|G|. The answer is always an integer — a fast sanity check on your census.

The “Divide by Symmetry” Trap, Formalized

Concept
When plain division is legal

The shortcut Answer=M/G\text{Answer}=M/|G| (over-count divided by the number of symmetries) is valid exactly when the group action is free: no nontrivial symmetry fixes any configuration, so every orbit has the full size G|G|. This is the regular/free case. Equivalently, by the orbit--stabilizer theorem,

orbit of x=GStab(x),|\text{orbit of }x| = \frac{|G|}{|\mathrm{Stab}(x)|},

so orbits all have size G|G| precisely when every stabilizer is trivial. If some configuration is fixed by a nontrivial gg (a symmetric coloring), its orbit is smaller than G|G|, plain division undercounts the collapse and gives the wrong answer, and you must use Burnside.

Example
Worked example: why 26/122^6/12 is wrong for bracelets

Naively “262^6 colorings, divide by 1212 symmetries” gives 64/12=5.3364/12=5.33\dots — not even an integer, a red flag. The action is not free: the all-black bracelet is fixed by all 1212 symmetries (stabilizer size 1212, orbit size 11), and a bracelet like BWBWBW is fixed by several rotations and reflections. These small orbits are exactly what Burnside's averaging accounts for, producing the correct 1313 from the previous section. Plain division is only correct for the asymmetric colorings, whose orbits genuinely have full size 1212.

Example
Worked example: seating where division is legal

Seat 77 distinct people around a round table; rotations are equivalent (no reflections). No nontrivial rotation can fix an arrangement of 77 distinct people, so the action of the 77 rotations is free and every orbit has size 77. Plain division is valid: 7!7=6!=720\frac{7!}{7}=6!=\boxed{720}. The distinctness of the objects is what guarantees freeness.

Tip

Decision rule: before dividing by G|G|, ask “could any nontrivial symmetry leave a configuration unchanged?” If the objects being arranged are all distinct and GG is just rotations, usually no — divide freely. If repeats are allowed (colorings) or reflections are included, symmetric configurations almost always exist — reach for Burnside. A non-integer after dividing is proof the action was not free.

Complementary Counting Meets Inclusion--Exclusion

Concept
Counting the complement of a union

The strongest complementary arguments subtract a union of bad events, and unions are handled by inclusion--exclusion:

A1An=NiAi+i<jAiAj+(1)nA1An.\Bigl|\,\overline{A_1\cup\cdots\cup A_n}\,\Bigr| = N - \sum_i |A_i| + \sum_{i<j}|A_i\cap A_j| - \cdots + (-1)^n\,|A_1\cap\cdots\cap A_n|.

Use this when “good” means “avoids every one of several forbidden features.” The intersections are usually easy products, even when the individual good count is a casework nightmare.

Example
Worked example: integers coprime-ish to 2,3,52,3,5

How many integers in {1,2,,1000}\{1,2,\dots,1000\} are divisible by none of 2,3,52,3,5? Let ApA_p be the multiples of pp. Then A2=500, A3=333, A5=200|A_2|=500,\ |A_3|=333,\ |A_5|=200; pairwise A6=166, A10=100, A15=66|A_6|=166,\ |A_{10}|=100,\ |A_{15}|=66; and A30=33|A_{30}|=33. The count divisible by at least one is

500+333+20016610066+33=734,500+333+200-166-100-66+33 = 734,

so the answer is the complement 1000734=2661000-734=\boxed{266}.

Example
Worked example: surjections via inclusion--exclusion

How many functions from a 55-element set onto a 33-element set {1,2,3}\{1,2,3\} are there? Let AiA_i be the functions that miss value ii. A surjection avoids every AiA_i, so

#(onto)=k=03(1)k(3k)(3k)5=35325+315=24396+3=150.\#(\text{onto}) = \sum_{k=0}^{3}(-1)^k\binom{3}{k}(3-k)^5 = 3^5 - 3\cdot 2^5 + 3\cdot 1^5 = 243 - 96 + 3 = \boxed{150}.

Direct casework on the “shape” of the preimages (3+1+13{+}1{+}1 vs. 2+2+12{+}2{+}1) also works but is error-prone; the complementary/IE form is mechanical.

Tip

Tip: inclusion--exclusion signs alternate, so a sign slip is the most common mistake. Check the last term's sign: with nn forbidden properties it is (1)n(-1)^n. Also verify a small case by hand (e.g. surjections from a 22-set onto a 22-set should give 22) before trusting the general formula.

Systematic Casework and Generating Functions

Concept
Choosing what to case on

Two cases are not equal in quality. Aim for a parameter that is most constraining and symmetry-friendly:

  • 2pt
  • Case on the extreme: the largest element, the maximum multiplicity, the position of the first success. Extremes split the problem into independent “above” and “below” pieces.
  • Exploit symmetry to fuse cases: if the roles of two variables are interchangeable, count one ordering and multiply (remember to halve the tie case). This can cut the case count in half or more.
  • Prefer few fat cases over many thin ones: a parameter taking 33 values, each an easy product, beats one taking 1212 values you must enumerate.
Concept
Generating functions as bookkeeping

A generating function replaces casework with algebra: the number of ways to choose objects with a target total is a coefficient in a product of polynomials/series. Each factor encodes one independent choice; multiplying performs the “add over all splits” automatically. Bounded choices give finite polynomials; a single die is x+x2++x6=x(1x6)1xx+x^2+\cdots+x^6=\dfrac{x(1-x^6)}{1-x}.

Example
Worked example: three dice summing to 1010 --- casework vs. GF

In how many ordered ways do three dice (11--66) sum to 1010? The generating function is (x+x2++x6)3\bigl(x+x^2+\cdots+x^6\bigr)^3, and we want the coefficient of x10x^{10}. Shift each die by 11 (let a=a1a'=a-1, etc.), so we need a+b+c=7a'+b'+c'=7 with 0a,b,c50\le a',b',c'\le 5. Unbounded stars and bars gives (92)=36\binom{9}{2}=36; subtract the solutions where some variable exceeds 55 (i.e. is 6\ge 6). Forcing one variable up by 66 leaves a sum of 11 among three nonnegative variables, (32)=3\binom{3}{2}=3 ways, and there are 33 choices of which variable overflowed (no two can overflow since 26>72\cdot 6>7). Thus

3633=27.36 - 3\cdot 3 = \boxed{27}.

Compare the raw casework: summing #{a+b=10c}\#\{a+b=10-c\} over c=1,,6c=1,\dots,6 forces you to track the 11--66 bounds on a,ba,b case by case; the GF/IE route handles every bound in one subtraction.

Tip

Tip: the substitution “a=a(lower bound)a'=a-(\text{lower bound})” turns any \ge constraint into a nonnegativity constraint so stars and bars applies; each upper bound violation is then removed by one inclusion--exclusion term (shift the offending variable past its ceiling). If at most one variable can overflow, that correction is a single clean subtraction, as above.

Formulas, Proofs & Tips

Tip
Complementary counting and casework
A=totalnot A|A| = |\text{total}| - |\text{not }A|

What it means. Sometimes it is easier to count what you do not want.

Example. At least one head in 33 flips: 1(12)3=781-\left(\tfrac12\right)^3=\tfrac78.

Why it works. Every outcome is either in AA or not, and never both, so the two counts partition the whole set and must add to the total.

Tip. Split into cases that are disjoint and exhaustive — no overlap, nothing missed — then add the case counts.