20
What is Hexagonification™?
Hexagonification™ is a transformation that creates a hexagon with 3 copies of a rectangle block, each skewed to the right by 30 degrees and then rotated by 0, 120 and 240 degrees respectively, as shown in the following image. A triangle hole may appear in the middle, but that isn't a great deal.
Challenge
Write a program or function that receives a block of string as an input and outputs the hexagonified™ input. You may assume that the input consists of only ASCII characters and new lines, and each line of the input has been padded so that all lines are of equal length. Empty spaces should be filled with space characters.
The input and output formats are flexible. You may receive a single string, a list of lines or a 2D array as input, and output a single string or a list of lines. You may have leading/trailing spaces on each line and leading/trailing newlines, provided that the hexagon is properly formed. See Sample IO for how the blocks should be positioned.
Sample IO
Input:
3x3
squ
are
Output:
3 x 3
e s q u
u r a r e
3 q a a s 3
x s r q x
3 e u 3
Input:
longer.....
rectangular
block......
Output:
l o n g e r . . . . .
. r e c t a n g u l a r
r . b l o c k . . . . . .
. a . b r l
. l . l e o
. u . o c n
. g . c t g
. n k k a e
r a c . n r
e t o . g .
g c l . u .
n e b . l .
o r . a .
l . r .
Input:
vb
el
ro
tc
ik
c2
ax
l8
Output:
v b
8 e l
x l r o
2 a t c
k c i k
c i c 2
o t a x
l r l 8
b e l a c i t r e v
v 8 x 2 k c o l b
Input:
1.line
Output:
1 . l i n e
e 1
n .
i l
l i
. n
1 e
Input:
1
.
l
i
n
e
Output:
1
e .
n l
i i
l n
. e
1 e n i l . 1
Scoring
Your score will be the area of the hexagonified™ source code (including the triangle hole). Assuming your code can just fit inside a rectangle of width \$w\$ and height \$h\$, the score will be:
$$3wh+\frac{(w-h)(w-h+1)}{2}$$
Winning Criteria
The submission with the lowest score in each language wins. No standard loopholes.
Isn't there a language, HexaGolf with a built-in for this? – 640KB – 2019-12-15T23:57:19.517
@640KB I'm not sure about that, but if there is such language, feel free to use it ;) – Shieru Asakoto – 2019-12-16T00:18:05.250
3
...waits with baited breath for a Hexagony answer.
– Jonathan Allan – 2019-12-16T12:06:09.8401May we accept a list of lines? May we return a list of lines? – Jonathan Allan – 2019-12-16T21:12:25.760
1@JonathanAllan Yes of course. Edited to reflect this. – Shieru Asakoto – 2019-12-16T22:11:24.120