This is the second in a series of posts designed to challenge your mind. As before, you may use any standard programming language to complete this challenge.
The challenge is to get from point A to point B in as few moves as possible. You can only move up, down, left and right (no diagonal moves). There is added complexity in that some points act as roadblocks and can be used as part of the route.
This is a visualisation of what the grid looks like. Starting point is 12 (in green) and the end point is 33 (in blue). The roadblocks are in red.
00 10 20 30 40
01 11 21 31 41
02 12 22 32 42
03 13 23 33 43
04 14 24 34 44
Your program should run from a single call to a function or class method that takes 3 paramaters like so:
The first is the starting coordinates (start_coords): 12
The second is the ending coordinates (end_coords): 33
The third is a set/array of the roadblocks (evil_coords): [13,22,23,31]
calculateRoute(start_coords, end_coords, evil_coords)
The function should return a set/array of coordinates that describe the shortest route from start_coords to end_coords (inclusive).
Your program should not hard code any routes and should calculate the route like a mouse would navigate a maze, not knowing what is around each turn. The grid itself IS hard coded 0-4 on the x axis and 0-4 on the y-axis.
Don’t scroll any further if you don’t want to see other people’s solutions.