r/ProgrammerHumor •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

615 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jun 11 '23

At an intersection: pick a random direction. At a dead end: reverse. Done.

If there's an exit and no time limit, it will find the exit. Loops, maze size, complexity, 3 or more dimensions, nothing matters. Randomness always works. It might take some time, but it will beat logic based approaches on complex situations where the logic isn't perfect (which it rarely is in unexpected situations).