Inspired by Kodenesia (written by Yanmarshus Bachtiar), this is my first attempt to write an algorithm problem for programming challenge.
Given the specific parameters (
target), you should build a virtual block map. If the
size is 10, then it will be a 10x10 blocks map. Each block is numbered sequentially from left to right, then top to bottom. The initial value for this sequence is 1.
size value is 6, then the map will be like this,
All numbers in the
wall value are considered as walls on the map, according to the matched block number. Consider the
wall value is
4,8,10,11,20,21,22,23,29,32, then the map will have walls (let’s assume they’re the grey blocks) like this,
If we set the
start value to 1 and the
target value to 27 then now we have a maze challenge like this,
The program should be able to find the fastest path from the
start to the
target. Only up, down, left and right moves are allowed, no diagonal move at all.
This path below may be a correct path to the target, but not the fastest one,
This is the correct and the fastest path,
In this case, the result of the program should be
wallstring (comma separated)
size: 10 <= x <= 100
wall: 1 <= x <= (
start: 1 <= x <= (
target: 1 <= x <= (
Array of block numbers that represents the solution from the
start to target
target (written in the comma separated string).