The challenge
Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. (String with newlines, list of string, list of list of chars, etc.) Print a truthy value if it will float, and a falsey value if it will sink.
A boat will tip over if the bottom has an inconsistent density, so every character of must be the same. Also, if a boat has large holes in it, represented by spaces, it will sink, so your boat must have no holes with an area greater than 4. Here is an example:
########
# ####
########
# ## ##
# #####
########
This boat is valid because the largest hole in it has an area of 4. This boat:
########
########
# ##
# #####
########
is invalid because it has a hole with an area of 7. You can safely assume that the outside of every input will be a solid rectangle with no holes. Here are some more tests:
$$$$$$$$
***$$$$$
***$$$$$
***$$$$$
$$$$$$$$
Invalid density. Sink.
%%%%%%%%
% % %
%%%%% %
% % %
%%%%%%%%
None of the holes are larger than 4. Float.
OOOOOOOO
OOOOOOO
OOOOOOOO
OOOOOOOO
OOOOOOOO
The outside border is not solid. Undefined.
&&&&&&&&&&&&&
& & & & & & &
&& & & & & &&
& & & & & & &
&& & & & & &&
& & & & & & &
&&&&&&&&&&&&&
Although I would not be comfortable riding in this boat myself,
none of the holes are larger than 4. It floats.
@@@@@
@ @
@ @
@ @
@@@@@
It sinks.
Rules
- IO can be in any reasonable format.
- Standard loopholes apply.
- Shortest answer in bytes wins.
- The given string will entirely consist of printable ASCII.
&
boat exists \$\endgroup\$