39
3
Introduction:
Inspired by this comment of @MagicOctopusUrn on @Emigna's 05AB1E answer for my "It was just a bug" challenge:
8F9ÝÀNð×ý}».∊
I done did made a spaceship maw! And I was all excited about suggesting a 12-byte edit. – Magic Octopus Urn Jul 17 '17 at 20:10
Which is a 05AB1E (legacy) program resulting in this:
1234567890
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1234567890
Challenge:
Input: A non-empty string
Output: From outwards going inwards, add one more space between each character every line, similar as done in the output above, equal to the length - 1
. So for an input 1234567890
the output would actually be this instead:
1234567890
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 0
1234567890
Why? The length of 1234567890
is 10
. So we start by outputting 10 lines: the first line without spaces; second with one space delimiter; third with two; etc. And then (without have the middle line with length - 1
spaces duplicated), we go back to the initial input while going down.
Challenge rules:
- Input is guaranteed to be non-empty (a length
>= 1
). (For single char inputs we simply output that character.) - Any amount of trailing/leading spaces/newlines are allowed, as long as the output itself (wherever on the screen) is correct. (Empty line(s) in between output lines also isn't allowed.)
- Input will only contain printable ASCII characters excluding whitespaces (code-point range
[33, 126]
) - I/O is flexible. Input may be taken as STDIN, argument, or function parameter. May be a list/array/stream of characters instead of string. Output may also be a list/array/stream of characters instead of strings; may be printed to STDOUT; returned as newline-delimited string; etc.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, adding an explanation for your answer is highly recommended.
Test cases:
Input: @
Output:
@
Input: test
Output:
test
t e s t
t e s t
t e s t
t e s t
t e s t
test
Input: ?!
Output:
?!
? !
?!
Input: Spaceship
Output:
Spaceship
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
S p a c e s h i p
Spaceship
Input: 05AB1E
Output:
05AB1E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
0 5 A B 1 E
05AB1E
Input: )}/\
Output:
)}/\
) } / \
) } / \
) } / \
) } / \
) } / \
)}/\
Can we return a list of lines? – Erik the Outgolfer – 2018-09-04T16:17:56.303
@EriktheOutgolfer Sure. – Kevin Cruijssen – 2018-09-04T16:18:24.527
1Gets all just jittery !!!SPACESHIP!!! – WallyWest – 2018-09-05T22:03:28.783
1I knew I recognized that output. I love that this idea is still going. – Carcigenicate – 2018-09-05T23:01:30.150
2TFW you vaguely recognize a pattern in a question
ಠ_ಠ
then realize it's because you accidentally made it a year agoಠ⌣ಠ
. – Magic Octopus Urn – 2018-09-06T17:25:10.1701@MagicOctopusUrn Thanks for the inspiration. ;D – Kevin Cruijssen – 2018-09-06T17:26:00.247
3@KevinCruijssen thanks for keeping the goofy quote haha! – Magic Octopus Urn – 2018-09-06T17:26:15.910