Grid traversal - MATLAB Cody - MATLAB Central

Problem 1963. Grid traversal

Difficulty:Rate

Given a line defined by (x1,y1) & (x2,y2),return the number of squares that the line crosses on the grid (a square is 1x1).

Coming next: return the number of squares for any geometrical shape

Solution Stats

34.38% Correct | 65.63% Incorrect
Last Solution submitted on Jun 25, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers27

Suggested Problems

More from this Author12

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!