We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Castle on the Grid
- Discussions
Castle on the Grid
Castle on the Grid
Sort by
recency
|
35 Discussions
|
Please Login in order to post a comment
This problm's got issues. Let's take the first test case:
[s X .] [. X .] [g . .]
to go from Start to Goal, there are two moves (0,0)->(0,1) and (0,1)->(0,2). But the expected answer is 3. How TF are they counting to get to 3? Can somebody please explain to me? Or, at least, share whatever the author was smoking?
If you're getting results that seem correct but don't match the expected results (e.g., 1 rather than 3 for sample test 0), it's probably because
x
andy
are not fully specified in the problem description, and you have them reversed. The first row of input is the columnx=0
rather than the rowy=0
. You can swap the X and Y argument names in theminimumMoves
function to resolve it.solution in C#:
i solved by building a graph of points on the grid and calculating distance using dijkstra's algo
If you are using BFS, simply blocking the previously visited spots might not work, you can try to add it if its cost is less.