, thanks!! Yes, I'm using Dijkstra's algorithm (even though I didn't explicitly mention it in the code), but it's implemented on getMinimumDistance function, where I basically do the following steps to get the minimum step between "start" and "end" squares:
The final distance between "start" and "end" is the smallest distance of all "end"'s unblocked neighbors.
Also, to break the ties in the reading order, it's all in getAdjacents function, where I look for the following neighbor squares and return in their reading order.
Considering we're getting adjacents for position X,Y, N=max(X) and M=max(Y)
In other words,
Oh, awesome. I got it. I want to come back after I've done others and revisit this problem with breadth-first-search. Maybe it'll be faster.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.