Can this container hold this much liquid?
As you most likely know, liquids have an indefinite shape and a definite volume. As such, they always take the shape of their container. They cannot, however, expand to fill their container.
Your job today is to determine whether or not a certain amount of liquid (represented by a certain number of
L characters or numbers representing the volume of the part, as per suggestion) can fit into a container of a certain size (represented by a matrix of
C characters) with some amount of empty space (represented by space characters) within it. The container will always have
C characters all the way around the perimeter.
Your program will return a truthy/falsey value based on whether the liquid will fit into the container. It will only fit if there is an area of connected empty space (made up of spaces adjacent to one another horizontally, diagonally, or vertically) within the container for each part of the liquid that is separated from the rest (either by a space or by two newline characters).
LLL L ----- True CCCCC C CC C CC CCCCC LLL LL ------ True CCCCCC C C C C CCC CCCCCC L L LLL ----- False (Not enough space) CCCCC CCCCC C CC CCCCC LL ------ False (Spaces are not connected but liquid is) CCCCCC CCCC C C CCCC CCCCCC L L ------ True CCCCCC CCCC C C CCCC CCCCCC L L ------ True (There is a pocket of empty space which holds both parts of the liquid) CCCCCC CCC C CCCCCC CCCCCC L L ------ True (There is a pocket of empty space for each part of the liquid) CCCCCC CCCC C C CCCC CCCCCC L L L LL ------ True CCCCCCCCC CCCC C C C CCCCCCC CCCCCC CC CCCCCCCCC L L ----- True CCCCC CCCCC C CC CCCCC
Feel free to suggest test cases!
- This is code-golf, so the shortest answer in bytes wins.
- Standard loopholes are disallowed.