Prime pathing, help!

I used a filtering algorithm to find all the find and save all the traps with a trap.vaule that was prime (using the provided test) to an array and then used a best choice algorithm using that array to find the next closest excluding the one I was standing on and only looking for ones in the proper direction.

There other ways to solve the level though…

(p.s. If you can’t remember what a flitering or best choice algorithm look like, check out my posters!)