Quoto

Courses / Combinatorics for interviews

Repairing an overcount

9 cards2 min readCombinatorics

Card 1 of 9
  1. Idea: Add, then repair

    Count each group alone, then subtract what you counted twice.

    • Multiples of up to :
    • Of : ; of both, that is of :
    • Total:
  2. Formula: Inclusion and exclusion

    Add the sets, then subtract the overlap once.

  3. Common mistake: Both means the least common multiple

    Divisible by and is not divisible by .

    Instead Use the least common multiple, . The product works only when the numbers share no factor.

  4. Idea: Why the signs alternate

    With more sets: add the singles, subtract the pairs, add the triples, and so on.

    • An element in sets:
    • Every element ends up counted exactly once
  5. Idea: Count what you do not want

    "Not adjacent", "at least one" and "none" signal the complement.

    • A pair not adjacent in a row of :
  6. Example: No letter in its own envelope

    letters go into addressed envelopes. In how many ways does no letter reach its own?

    1. At least one right:
    2. None right:
  7. Formula: Derangements

    Start from D(1) = 0 and D(2) = 1. The share of derangements settles near 1/e.

  8. Quick check: 5 letters, 5 envelopes

    In how many ways can letters go into addressed envelopes with no letter in its own?

    Show the answer

    Answer:

    , which is .

  9. Idea: Narrate the correction

    State the sets, then what got counted twice and how you repair it.

    • Say so before you switch to the complement
    • Close with a case you can list, such as