Challenge
Given a graphical input of a shape, determine how many holes there are in it.
Not Duplicate
This question was marked as a possible duplicate of Count Islands. I believe this challenge is different from the Count Island challenge because in this one, you have to figure out how to eliminate blocks that touch the border.
Input
Input will be given as some 2D form of input, either a multiline string, an array of strings, or an array of character arrays. This represents the shape. The shape is guaranteed to be in only one piece, connected by edge. Please specify how you want input to be taken.
Output
Output is a single integer stating how many holes there are in the shape. A trailing newline is permitted, but no other leading or trailing whitespace. In other words, the output must match the regular expression ^\d+\n?$
.
What is a hole?
These are single holes:
####
# #
# #
####
####
# #
# ##
###
#####
# # #
# #
#####
These are not holes:
########
########
# ####
# ####
# ######
#
########
###
#
###
##########
#
# ########
# # #
# # #### #
# # ## #
# ###### #
# #
##########
Pretty much, if it the gap joins the outside edge, it is not a hole.
Test cases
#####
# # # -> 2
#####
#####
#
# ### -> 1
# # #
#####
####
## # -> 1 (things are connected by edges)
# ##
####
###
### -> 0 (You must handle shapes with no holes, but input will always contain at least one filled space)
###
You can use any character in place of the '#', and in place of the spaces.
Objective Scoring Criteria
The score is given as the number of bytes in your program.
Winning
The winner will be the submission with the lowest score, by April 4th.
###|# #|##
as a test case? That should be0
, right? \$\endgroup\$