Puzzles
12Puzzles
These puzzles turn a concrete counting question into a general formula. The pattern worth noticing across all of them is the same one behind dynamic programming and combinatorial algorithms: observe a small case, find the rule connecting it to the next case, and let that rule scale to any size.

At a party of n people, every person shakes hands with every other person exactly once.
Rules
Your task — Find a formula for the total number of handshakes in terms of n, and check it for n equal to 10.
Difficulty — Easy
Hint 1 — Think of choosing pairs.
Hint 2 — Each person shakes n minus 1 hands.
Hint 3 — Avoid counting each handshake twice.
Main idea — Counting each person's handshakes and then correcting for double-counting lands on the same answer as simply choosing 2 people out of n.
Solution
Reasoning
This is exactly the combinatorial idea of choosing 2 items from a set of n without regard to order, written as "n choose 2."
It also matches the number of edges in a complete graph on n vertices, a connection that shows up throughout graph algorithms and combinatorial counting in programming.

A standard chessboard is an 8 by 8 grid of unit squares.
Rules
Your task — Find the total number of squares of all sizes that can be found on the board.
Difficulty — Medium
Hint 1 — Count squares size by size.
Hint 2 — A size k square fits (9 minus k) ways per row.
Hint 3 — Sum the squares of those counts.
Main idea — The number of positions for each size of square is itself a perfect square, so the total is simply the sum of the first 8 square numbers.
Solution
Reasoning
Each square size contributes a perfect square number of positions, because the square's top-left corner has (9 minus k) valid choices in each of two independent directions.
Summing these squared counts across all 8 sizes is the classic sum-of-squares formula in disguise, the same pattern that shows up in nested-loop counting problems in programming.

On the same 8 by 8 chessboard, a rectangle is any shape formed by choosing two horizontal grid lines and two vertical grid lines.
Rules
Your task — Find the total number of rectangles of any shape that can be found on the board.
Difficulty — Medium
Hint 1 — Rectangles come from line pairs.
Hint 2 — Choose 2 of 9 lines each way.
Hint 3 — Multiply the two choice counts.
Main idea — Every rectangle is uniquely set by picking any 2 of the 9 horizontal lines and any 2 of the 9 vertical lines, turning the whole problem into a simple combination count.
Solution
Reasoning
Choosing any 2 horizontal lines and any 2 vertical lines always defines exactly one rectangle, and every rectangle on the board can be described this way, with no overlap or omission.
This turns a seemingly geometric counting problem into a pure application of combinations, the same "choose" logic used throughout combinatorics and probability.

A staircase has n steps, and at each move you can climb either 1 step or 2 steps at a time.
Rules
Your task — Find a rule for the number of distinct ways to reach the top of an n-step staircase.
Difficulty — Easy
Hint 1 — How do you reach the last step?
Hint 2 — Two ways to land there.
Hint 3 — Add the two smaller cases.
Main idea — Since the very last move is either a single step from step n minus 1 or a double step from step n minus 2, the total ways to reach step n is just the sum of the ways to reach those two earlier steps.
Solution
Reasoning
Breaking the problem down by the very last move made is a classic technique for building a recurrence relation, and here it produces the same recurrence that defines the Fibonacci sequence.
This is a direct bridge to dynamic programming, where storing and reusing f(n minus 1) and f(n minus 2) turns an exponential brute-force search into a simple linear-time calculation.

A convex polygon has n vertices.
Rules
Your task — Find a formula for the total number of diagonals in an n-sided polygon.
Difficulty — Easy
Hint 1 — Start from all possible connections.
Hint 2 — Subtract the polygon's own sides.
Hint 3 — Each side removes one connection.
Main idea — Counting every possible line between any two vertices and then removing the ones that are actually sides of the polygon leaves exactly the diagonals.
Solution
Reasoning
Since a polygon's vertices form a complete set of pairwise connections, subtracting only the segments that coincide with actual polygon edges isolates the diagonals precisely.
This overcount-then-subtract strategy, count everything then remove what doesn't belong, is a common combinatorial technique that also appears in inclusion-exclusion counting problems.

n people are to be seated around a circular table, where seatings that are rotations of each other are considered the same arrangement.
Rules
Your task — Find a formula for the number of distinct seating arrangements.
Difficulty — Medium
Hint 1 — Fix one person's seat.
Hint 2 — Arrange everyone else normally.
Hint 3 — That's (n minus 1) factorial.
Main idea — Fixing one person's position removes the rotational symmetry entirely, turning a circular arrangement problem into an ordinary problem of arranging the remaining people in a line.
Solution
Reasoning
Every rotation of a full circular arrangement is considered identical, and there are exactly n such rotations for any arrangement of n people, so dividing the usual n factorial linear arrangements by n leaves (n minus 1) factorial distinct circular arrangements.
Fixing one person's seat achieves the same result directly, without needing to divide afterward.

You want to cut a flat, round pizza using n straight-line cuts, where each cut is a full straight line across the pizza.
Rules
Your task — Find a formula for the maximum number of pieces achievable with n straight cuts.
Difficulty — Hard
Hint 1 — Each new cut crosses all before it.
Hint 2 — Every crossing adds one region.
Hint 3 — Add the cut number to the running total.
Main idea — To maximize pieces, each new cut should cross every previous cut at a different point, and every such crossing adds exactly one new region to the total.
Solution
Reasoning
A new straight line can add at most one new region for every previous line it crosses, since each crossing splits an existing region into two.
Maximizing crossings means every new cut should intersect all earlier cuts at distinct points, which leads directly to the well known plane-cutting formula, closely related to the triangular numbers used throughout combinatorics.

5 people, including a specific couple, need to be seated in a row of 5 chairs, and the couple insists on sitting next to each other.
Rules
Your task — Find the number of distinct seating arrangements satisfying this restriction.
Difficulty — Medium
Hint 1 — Treat the couple as one unit.
Hint 2 — Arrange that unit with the rest.
Hint 3 — Then arrange the couple internally.
Main idea — Gluing the couple together into a single block turns the problem into arranging fewer, ordinary units, then separately accounting for the two ways the couple can be ordered inside that block.
Solution
Reasoning
Bundling the constrained pair into a single unit removes the adjacency requirement from the counting process entirely, since arranging units automatically keeps the pair together.
Multiplying by the internal arrangements of the bundled unit accounts for every valid ordering, a standard technique for handling adjacency constraints in permutation counting.