Propagation of the fire!

Hi everybody, I would like to ask you if there is any "trick" or "fast way" of doing the following program.

You are given a Matrix of chars. For every char there are 3 possibilities: that it is a dot '.' which means the position is empty, that it is a 'T' which means that there is a tree and that there is an 'F' which means that there is a fire.

If in the position i,j of the matrix, there is a fire then the directly, top, left, right and bottom positions get also in fire if there was a tree 'T' in them.
The initial position that was in fire becomes empty '.' in the next step.

The objective of the program is to write a function, that given a certain Matrix M with (maybe) a fire, prints the outcome of propagating the fire until there is no fire left.

Thanks!
So, if M is
.T
FT

and you copy it into a larger array A (and count fires as you go):
....
..T.
.FT.
....

Now you can fill array B according to your rules, without doing the edges (which were initialized to empty):
....
..T.
..F.
....

Swap A and B, and you have done one iteration. There is still fire, so you end up doing two more iterations:
....
..F.
....
....
....
....
....
....

Count of fires is 0, so you copy result back to M:
..
..


Now, the "fast way" to fill B from A is to use parallel computation.
Topic archived. No new replies allowed.