Finding the shortest path between two points on a grid, using Haskell.
Posted
by esperantist
on Stack Overflow
See other posts from Stack Overflow
or by esperantist
Published on 2010-03-15T23:09:24Z
Indexed on
2010/03/15
23:29 UTC
Read the original article
Hit count: 688
This is a problem that I can easily enough solve in a non-functional manner.
But solving it in Haskell is giving me big problems. Me being inexperienced when it comes to functional programming is surely a reason.
The problem:
I have a 2D field divided into rectangles of equal size. A simple grid. Some rectangles are empty space (and can be passed through) while others are impassable. Given a starting rectangle A and a destination rectangle B, how would I calculate the shortest path between the two? Movement is possible only vertically and horizontally, in steps a single rectangle large.
How would I go about accomplishing this in Haskell? Code snippets certainly welcome, but also certainly not neccessary. And links to further resources also very welcome!
Thanks!
© Stack Overflow or respective owner