MathsReadCompetitive mathematics
Algorithmic puzzle · integer answereasy25 min

Two forbidden rectangles

Combinatorial Counting

Count paths from (0,0) to (20,15), taking only (x+1,y) or (x,y+1), without visiting any lattice point with 4<=x<=7 and 3<=y<=5, or 12<=x<=14 and 8<=y<=10.

Solve using mathematics, algorithms, or your own code offline. Submit only the final integer here—no program, expression, graph, or written proof.

Check your answer without signing in. Sign in to save your progress.

Accepted format: a whole number such as 42 or 123456789. No commas, formulas, or source code.

How to approach this problem

Fill a grid of path counts from the origin. Set every forbidden vertex to zero, and otherwise add the counts from the left and below. Take care to include the entire forbidden rectangle.

Worked example with different values

In a 2-by-2 destination grid, the six unrestricted monotone paths include four through (1,1). Blocking that point leaves two.

Apply the same reasoning to the challenge. This example is a separate practice problem.

Learn the technique: Dynamic programming and grid paths

Report a question or explanation issue

Back to problems →