Last Thursday user @SpookyGengar delighted us with his/her first challenge about Making Squared Words. What if we double the number of sides?
The challenge
Take a string as input in any reasonable format you need (string
, char
array...) and output an octogonal representation of the input (also in any reasonable format: string
, list of string
s, char
matrix...) as in the next examples:
Input: golf
Output:
golf
o l
l o
f g
l o
o l
g f
o l
l o
flog
Input: HelloWorld
Output:
HelloWorld
e l
l r
l o
o W
W o
o l
r l
l e
d H
l e
r l
o l
W o
o W
l o
l r
e l
H d
e l
l r
l o
o W
W o
o l
r l
l e
dlroWolleH
Input: a
Output:
a
Input: ab
Output:
ab
b a
a b
ba
Input: code golf
Output:
code golf
o l
d o
e g
g e
o d
l o
f c
l o
o d
g e
e g
d o
o l
c f
o l
d o
e g
g e
o d
l o
flog edoc
Notes
- Input will consist only of printable ASCII characters.
- Leading and/or trailing whitespaces and newlines allowed as long as the octogonal shape is maintained.
- This is code-golf, so may the sortest program/function for each language win!
code golf
\$\endgroup\$<Space>
considered printable? \$\endgroup\$