To simulate a zombie invasion, start with a grid of #
and representing the map:
## ##
### #
## ##
# ###
# ####
#
represents land.represents water.
The zombies start at a point on the map...
## ##
### #
## %#
# ###
# ####
...and spread. %
denotes land infected by zombies.
However, zombies cannot swim. They can move across land in the same way a king moves in chess - one square in any diagonal or orthogonal direction:
!!!
!%!
!!!
At the end of the simulation, some land will be infected with zombies:
%% ##
%%% #
%% %%
% %%%
# %%%%
Your task is to simulate the zombie invasion. Write a program (or function) that takes as input a string representing the initial state of the grid, and two numbers representing the coordinates of the initial zombie. The program should output (or return) the final state of the invasion.
Specifications
- Your program may print an optional trailing newline.
- You can assume the input will be in the correct format (padded with spaces), with an optional trailing newline.
- You can assume the initial zombie will start on land and will not die immediately.
- This is code-golf, so the shortest answer (in bytes) wins.
- -100% bonus if your code can also solve the Halting Problem for arbitrary Turing machines.
- Your program should handle board widths of up to 50 chars.