Inspired by my geography class, Sandboxed
Simulate weathering / erosion.
Input
Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes):
###
####
#####
#######
#######
########
Or if your language doesn't support strings, a square matrix of 1s and 0s, a matrix of chars, whatever makes your answer more golfier.
Process
The rock will erode until it disappears completely. Lets take example of input:
##
## ### #
#########
###########
First we find which part of the rock is exposed (that is there is no rock particle directly above / below / left / right) to the air (i use @ to show such particles here):
@@
@@ @#@ @
@##@###@@
@########@@
NOTE: The bottom most rock particles are touching the ground and they are not touching air, hence we don't count these particles.
Then we randomly (50% chance individually for each particle) remove the rock particles (here #) (apply gravity similar to this challenge that are exposed to the air:
#
##
## ### #
##########
And be repeat the process until the rock disappears and output the rock in between each iteration (including the original input). In this case we output:
##
## ### #
#########
###########
#
##
## ### #
##########
## ##
#########
# #
## #### #
#
# # # #
# #
This is code-golf, answer in the shortest amount of bytes wins.
"###/#.#/###"
is possible in real life. And the#
in top middle will not fail down. \$\endgroup\$"# #\n# #\n###"
would be output in the first iteration as" # # \n # # \n ### "
- the output will always be two wider than the input with padded spaces)? \$\endgroup\$'##\n\n###'
which is not possible in real life. \$\endgroup\$