Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.
I am an evil farmer, and to drive up the price of wheat in my area, I've decided to burn the fields of all the farmers around me. I would really like to see the fields go up in flames (so I can use my evil laugh and rub my hands together with glee), but I also don't want to be caught watching, so I need you to simulate the field being incinerated for me.
Your Task:
Write a program or function that takes as input a field, and returns the stages of it burning until the entire field is ash. A specific section of the field that is on fire is represented by an integer representing the intensity of the flame. A fire starts at "1" and moves on to "2" and then "3", and so on. Once a fire reaches "4", it catches any directly (not diagonally) adjacent areas that are flammable on fire. Once it reaches "8", it burns out on the next iteration, and turns into ash, represented by an "A". When an area has not yet been touched by fire, it is represented by a "0". For example, if the field looks like this:
100
000
Your program should output this:
100
000
200
000
300
000
410
100
520
200
630
300
741
410
852
520
A63
630
A74
741
A85
852
AA6
A63
AA7
A74
AA8
A85
AAA
AA6
AAA
AA7
AAA
AA8
AAA
AAA
If you wish, you may replace the above symbols with any set of symbols you choose, as long as they are consistent and distinct from each other.
Input:
The starting position of the field, in any standard form, such as a newlined-delimated string as above.
Output:
The field in every iteration as it burns, either as an array, or as a string delimited by some character.
Test Cases:
0301
000A
555
|
v
0301
000A
555
1412
010A
666
2523
020A
777
3634
030A
888
4745
141A
AAA
5856
252A
AAA
6A67
363A
AAA
7A78
474A
AAA
8A8A
585A
AAA
AAAA
6A6A
AAA
AAAA
7A7A
AAA
AAAA
8A8A
AAA
AAAA
AAAA
AAA
Scoring:
This is code-golf, lowest score in bytes wins!