Algorithm Complexity problem

The task is to find the shortest way from me ('S') to the hut('D') without touching the flood ('*') or the rock ('X'), for each step I take, the flood spreads in all 4 directons by one field (up, down, left, right) and next step all those new fields spread up down left right. I can move left, right, up and down. I dont wont to solve it using recursion which uses brute force (test each possible way) so every idea/algorithm you think of is appriciated!

Test Examples:
1. example
3 3 It should cout 3
D.*
...
.S.

2. example
3 3 It should cout "NO" because S cant reach the D because of the flood
D.*
...
..S

3. example
3 6 It should cout 6.
D...*.
.X.X..
....S.
Last edited on
Breadth first search
A star
Dijkstra

These are all names of algorithms that can accomplish this, look them up if you want
Topic archived. No new replies allowed.