24
2
Given an ASCII art hexagon as input, output one whose sides are all one unit longer.
_____
____ / \
/ \ / \
/ \ / \
\ \ => \ \
\ / \ /
\____/ \ /
\_____/
The input hexagons will have 180 degree symmetry, but otherwise the sides can be all different lengths. Above, the side lengths (2, 4, 3) get enlarged to (3, 5, 4). The side lengths will be nonzero.
The hexagons are made of underscores _
, slashes /
, and backslashes \
. Note that of the horizontal edges (made with underscores), the top edge is on its own line but the bottom edge is not.
I/O
I'm going to be a stickler and require ascii-art formatting here: the input and output should be a string with newlines representing the image, not a list of lines. Of course, your code may print each line in turn to produce the image, or read STDIN a line a time for input if your language can do that.
Details
The input may include an optional trailing newline if you wish, but will otherwise have no empty lines. You can choose to either have no trailing spaces in the input, or spaces to pad each line to the same length (that of the longest line).
The output should be flush with the left edge of the screen, like the input. You may have extra newlines above and below as well as trailing spaces.
Test cases
Input followed by output.
_
/ \
\_/
__
/ \
/ \
\ /
\__/
____
/ \
/ \
\ \
\ /
\____/
_____
/ \
/ \
/ \
\ \
\ /
\ /
\_____/
_
/ \
/ /
/ /
/ /
/ /
\_/
__
/ \
/ \
/ /
/ /
/ /
/ /
\ /
\__/
Leaderboard
<iframe src="https://xmikee1.github.io/ppcg-leaderboard/?id=185760" width="100%" height="100%" style="border: none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe><style>html,body{margin:0;padding:0;height:100%;overflow:hidden}</style>
Must the output hexagon be the same one but bigger, or can it be any hexagon with the appropriate side lengths? – Stephen – 2019-05-18T02:47:42.093
1@Stephen It must be the same one but bigger, in the same orientation. – xnor – 2019-05-18T02:48:43.787
2This is a great example of a really well written challenge. Short, clear and to the point. May I make a small suggestion? "Stickler" may not be clear for all non native English speakers. May I suggest that "I will only accept..." or something similar may be easier to understand? +1 anyway. – ElPedro – 2019-05-18T20:43:45.197
Can we return an array/
IEnumerable
of characters? – Embodiment of Ignorance – 2019-05-19T01:23:00.427@EmbodimentofIgnorance Yes, those are fine, as long as the have the required newline characters. – xnor – 2019-05-19T03:06:03.027