Given the topography of land in ASCII picture format, figure out where lakes would go and fill them in. Assume an infinite amount of rain.
example
input
#
##
# ####
# #########
## ###########
## ############# ####
## ############## #####
################# #######
#########################
#########################
output
#
##
#@####
#@@@@#########
##@@###########
##@#############@@@####
##@##############@@#####
#################@#######
#########################
#########################
The input will contain only spaces and #
marks. Each line will be the same length. The output should be the identical #
pattern with spaces where water would accumulate filled in with @
marks.
The bottom input row will always be all # marks. There will be no holes or overhangs in the land. Shortest code wins.
@
that were filled in. \$\endgroup\$([char[]]"$a"-eq'@').Count
here. Not that much too add. Agreed on this being a little too easy, though. Doesn't fall into the realm of what I'd downvote, though. \$\endgroup\$