You're given a hexagonal grid of the characters .
and #
, like this:
. . . . . . . .
. . . . # . . .
. # . . . # . .
. . . # . . . .
. . . . . # . .
. . . . . . . .
Your task is to fill the entire axis-aligned bounding box of the #
with further #
:
. . . . . . . .
. . # # # # . .
. # # # # # . .
. . # # # # # .
. . # # # # . .
. . . . . . . .
The axis-aligned bounding box is the smallest convex hexagonal shape which contains all the #
. Note that in the case of the hexagonal grid, there are three axes to consider (W/E, SW/NE, NW/SE):
Here is another example to show that in some cases, one or more sides will contain only one #
:
. . . . . . . . . . . . . . . .
. # . . . . . . . # # # # . . .
. . . . . # . . . . # # # # . .
. . # . . . . . . . # # # . . .
. . . . . . . . . . . . . . . .
You can either view these as hexagons with degenerate sides, or you can draw the bounding box around them, like I have done above, in which case they are still hexagons:
Too hard? Try Part I!
Rules
You may use any two distinct non-space printable ASCII characters (0x21 to 0x7E, inclusive), in place of #
and .
. I'll continue referring to them as #
and .
for the remainder of the specification though.
Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.
You may assume that the input contains at least one #
and all lines are the same length. Note that there are two different "kinds" of lines (starting with a space or a non-space) - you may not assume that the input always starts with the same type. You may assume that the bounding box always fits inside the grid you are given.
You may write a program or a function and use any of the our standard methods of receiving input and providing output.
You may use any programming language, but note that these loopholes are forbidden by default.
This is code-golf, so the shortest valid answer – measured in bytes – wins.
Test Cases
Each test case has input and output next to each other.
# #
. . . .
# . # # # #
. . . .
. # . #
. . . . # .
# . # .
# . # .
. . . . # .
. # . #
# . # .
# . . # # .
. # # #
. # # #
# . . # # #
. # # #
. . # . # #
. . # #
# . . # # .
# . . # # .
. . # #
. . # . # #
. . . . . . . . . . . . . . . .
. . # . # . . . . . # # # . . .
. . . . . . . . . . . # # . . .
. . . # . . . . . . . # . . . .
. . . . . . . . . . . . . . . .
. . # . . . # . . . # # # # # .
. . . . . . . . . . . # # # # .
. . . # . . . . . . . # # # . .
. . . . . . . . . . . . . . . .
. # . . . . . . . # # # # . . .
. . . . . # . . . . # # # # . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. # . . . . . . . # # # # . . .
. . . . . # . . . . # # # # . .
. . # . . . . . . . # # # . . .
. . . . # . . . . . # # # # . .
. # . . . # . . . # # # # # . .
. . . # . . . . . . # # # # # .
. . . . . # . . . . # # # # . .