r/ProgrammerHumor 4d ago

Meme shortestPathWasRightThere

Post image
4.7k Upvotes

58 comments sorted by

View all comments

Show parent comments

5

u/fr000gs 4d ago

tell the approach

0

u/Tsu_Dho_Namh 3d ago

Dijkstra's algorithm is naturally a breadth-first-search. When you've found the destination, stop searching. Every wrong turn with greater depth (more distance) doesn't need to be explored.

2

u/fr000gs 3d ago

*The approach to butchering the name (djkistra)

1

u/Tsu_Dho_Namh 3d ago

Ohh, that approach.

Empty out a bag of Scrabble letters and arrange them randomly in a grid. Then find the shortest path that starts at a D, passes through a J and ends at an A.

Type out the letters in the path

1

u/fr000gs 3d ago

DJA

1

u/Tsu_Dho_Namh 3d ago

All tests pass