Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C

Problem: The number of paths from the bottom-left to the top-right corner of a 4×4 grid of points, moving only right, up, or diagonally up-right by one step, is what value?

  1. A. 20
  2. B. 321
  3. C. 63
  4. D. 27

Correct answer: C. 63

A 4 × 4 grid of points needs 3 rights and 3 ups; with diagonals this is the Delannoy number D(3, 3) = Σ C(3, k)·C(6 − k, 3) = 63. Without diagonals it is C(6, 3) = 20, treating it as 4 × 4 cells gives D(4, 4) = 321, and 3³ = 27 assumes three free choices.

More Coding Interview Problems questions

Exams that ask this topic