Solve a maze posted in StackOverflow