http://dwite.ca/questions/haunted_house.html [Broken](adsbygoogle = window.adsbygoogle || []).push({});

So this is from a contest I wrote a while back, I took the greedy approach for my solution, and I did get 5/5, but my solution was not totally correct because the shortest path was not guaranteed, if a candy was 2 spaces before the start, and a candy was 1 space in front, my algorithm would go to the candy 1 space in front, then to the one 2 spaces back, and then carry on. But to finish this algorithm correctly you would need to figure out all permutations of paths through the candies. So how would I even start to do that? It has been bugging me for a while now.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Permutations with BFS

**Physics Forums | Science Articles, Homework Help, Discussion**