0PricingLogin
Competitive Programming Academy · Lesson

Grid Walks and Direction Vectors

Move with dx, dy and stay in bounds.

Walking on a Grid

Many simulations happen on a grid of rows and columns. A token starts somewhere and moves cell by cell following directions. 🗺️

Track Row and Column

Hold your position as a (r, c) pair. Row indexes the line top to bottom and column indexes left to right.

r, c = 0, 0

All lessons in this course

  1. Model State and Step Forward
  2. Grid Walks and Direction Vectors
  3. Cycle Detection in Simulations
  4. Tame the Tricky Edge Cases
← Back to Competitive Programming Academy