38
4
The Challenge
Your task is to create a program that takes any given string input, and outputs the input in a squared format. Empty strings should return an empty string.
Examples
Given the input:
golf
Your program should output:
golf
o l
l o
flog
Input:
123
Output:
123
2 2
321
Input:
a
Output:
a
Input:
Hello, world!
Output (notice the space between the , and w - the gap is not just a newline):
Hello, world!
e d
l l
l r
o o
, w
w ,
o o
r l
l l
d e
!dlrow ,olleH
Scoring
This is code-golf, so the shortest answer in each language wins.
@DJMcMayhem Yes, my apologies I had forgotten to add that. – SpookyGengar – 2017-07-20T21:47:07.827
2No worries, just double checking. Nice first challenge BTW! Welcome to the site :) – James – 2017-07-20T21:47:28.017
@SpookyGengar Would you add a test case for a one-letter input? – musicman523 – 2017-07-20T21:58:45.377
@musicman523 don't I already have one? The third example involving just the letter 'a'. – SpookyGengar – 2017-07-20T21:59:55.903
Is empty string allowed to output to STDERR? (aka can I error out for null input) – Stephen – 2017-07-20T22:01:13.407
1@SpookyGengar my bad, I'm blind apparently – musicman523 – 2017-07-20T22:01:42.843
Ooh, this gave me an idea I have forgotten a while ago. – Matthew Roh – 2017-07-21T09:36:49.257
Do you accept the input itself as a part of the output? As in - the program doesn't output the the top line? That's the design of this answer: https://codegolf.stackexchange.com/a/133927/71498 and I'm looking for confirmation before I retract my downvote.
– Coty Johnathan Saxman – 2017-07-31T05:32:28.773Do you accept the output as a list of (meta-approved) strings that do not have newline characters? Some solutions (e.g. Haskell) are already doing things that way, but I wanted to check. – Mark S. – 2017-08-12T15:29:54.687