13
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.
what is halting problem? – Mukul Kumar – 2016-12-07T04:33:47.647
3
@MukulKumar https://en.wikipedia.org/wiki/Halting_problem. It's a joke. The Halting Problem is impossible to solve.
– Esolanging Fruit – 2016-12-07T04:34:53.1631you never know :P – Mukul Kumar – 2016-12-07T04:47:09.623
@MukulKumar Well, It's hard to argue with a proof. Turing knew what he was doing (And if he didn't, than no computer scientist knows what they're doing.) – Esolanging Fruit – 2016-12-07T04:57:39.620
Do we need to output every
step
or justfinal
stage? – Mukul Kumar – 2016-12-07T04:58:32.440So, all we need to do is prove mr.turing wrong and we win this challenge !! YAY! – Mukul Kumar – 2016-12-07T05:00:30.817
@MukulKumar Just the final step. – Esolanging Fruit – 2016-12-07T05:01:34.600
Is there any specific height-width or (max) height-width ? – Mukul Kumar – 2016-12-07T05:08:01.747
Let's say size < 50 – Esolanging Fruit – 2016-12-07T05:08:51.353
1
Related: http://codegolf.stackexchange.com/questions/83808/flood-fill-a-2d-grid
– Angs – 2016-12-07T07:29:09.0701No, seriously, I'd lift the bonus for the halting problem solution to -200%. The answer would deserve it. :) – RudolfJelin – 2016-12-07T20:21:51.190
@RudolfL.Jelínek But that adds an incentive to write a long program that solves the halting problem which makes it basically code-bowling :-) – Esolanging Fruit – 2016-12-07T22:26:06.503
Surprised nobody has done this in vi yet. – SIGSTACKFAULT – 2016-12-08T15:13:06.117