I like this one the best, this kata screams for recursion, and you hit the nail on the head.
Here is how it "snakes" through this sample city each step of the way (notice how the 8's on the right side don't get infected):
var city = [ [8, 8, 8, 8, 8, 7, 8], [1, 1, 1, 1, 8, 7, 8], [8, 8, 8, 1, 8, 7, 8], [8, 1, 1, 1, 8, 7, 8], [8, 8, 8, 8, 8, 7, 8]];
[[1,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,0,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,0,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,1,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [1,1,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [0,0,0,0,1,0,0], [1,0,0,0,1,0,0], [1,1,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [1,0,0,0,1,0,0], [1,0,0,0,1,0,0], [1,1,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [1,1,0,0,1,0,0], [1,0,0,0,1,0,0], [1,1,1,1,1,0,0]] [[1,1,1,1,1,0,0], [0,0,0,0,1,0,0], [1,1,1,0,1,0,0], [1,0,0,0,1,0,0], [1,1,1,1,1,0,0]]
Loading collection data...
I like this one the best, this kata screams for recursion, and you hit the nail on the head.
Here is how it "snakes" through this sample city each step of the way (notice how the 8's on the right side don't get infected):