CodeNFacts
CodeHub
Home

All Categories


Sign In
maze.runtime // energy-constrained pathfinding

Complexity Escape

A maze. Every wrong algorithm consumes energy. Find the shortest path before the budget hits zero — and along the way, greedy, BFS and DFS stop being words in a textbook.

> maze.load() > every_wrong_turn -= energy > shortest_path = required > learning: greedy, bfs, dfs — by feel
Novice Circuit · questions0/60 cleared
G

Arrow keys / WASD also work.

Energy
95 left95 budget
Run stats
Steps taken0
Energy spent0
BFS-optimal cost63
Grid size7×7
Field note

Trace the route in your head before you move — backtracking costs energy twice.

Field notes — what each search actually does
Breadth-First SearchExplores in rings, one step out at a time. It never skips a shorter route to try a longer one first, so the first time it reaches the exit, that route is guaranteed shortest.
Depth-First SearchCommits to a direction and rides it to the wall before backing up. Cheap to run, but it happily wastes moves down dead ends that BFS would never enter.
Greedy Best-FirstAlways steps toward whatever looks closest to the exit in a straight line. Fast when the maze cooperates, easily fooled when the straight line is walled off.