aptrobo.Back to lesson 1

FREE LESSON 2 · NO ACCOUNT NEEDED

Which route is shortest?

Reaching the goal is only the first question. Now compare the number of moves. Every move costs one step; move up, down, left or right, never diagonally.

1. Compare two delivery routes

Both maps have the same start S, goal G and obstacle. Count moves between cells, not the number of cells.

Route A · 6 moves

Route B · 8 moves

Which route uses fewer moves?
Your next step

Compare the two routes, then check your answer.

Need a hint?

The straight route needs four moves, but the obstacle blocks it. Going one row above or below adds two moves: six in total. There is more than one shortest route.

Free and optional. Progress stays on this page and resets on reload. Anonymous daily counts record opens, first comparison attempts, first route checks and completions, at most once each per page load. Your route and answers are not saved; browser measurement preferences apply. No certificate, kit or tutor is included.

Write your own BFS planner: free Python tutorial

Return to the first lesson