11
1
Sandbox post here.
Create a function or program that "Springifies" a string.
- Input will be a String in Stdin, or closest alternative
- Input will only contain printable ASCII and/or spaces
- Output will be to Stdout, or closest alternative
- A trailing newlines and spaces are acceptable
How to springify a String
- Format the String into as many ASCII spring coils as needed
- Pad the coils with spaces, up to the nearest coil
- Read off the characters, following the spring around the coils
This is an ASCII spring coil:
#
# ####
# #
# ####
#
Where the #
s are the characters of the String
Here is an example:
abcdefghijklmnopqrstuvwxyz
becomes
a
b cdef
g h
i jklm
n
o
p qrst
u v
w xyz.
.
Where the .
s replace spaces for visibility.
Then, the string is read back, following the ASCII spring downwards, around the loops, hitting the g
and u
twice:
1| a <-3
V b cdef
g h
4| i jklm
V n 2->
...
...giving:
abgjklmhfedcginopuxyz vtsrquw
(with a trailing space)
Test Cases
(quotations added to highlight trailing spaces - please ignore in terms of IO)
I: "abcdefghijklmnopqrstuvwxyz"
O: "abgjklmhfedcginopuxyz vtsrquw "
I: "!@#"
O: "!@ # "
I: ""
O: ""
I: "12345 67890"
O: "12690 7 54368 "
I: " "
O: " "
Note that the output length is always a multiple of 15, the length of a spring coil
This is code-golf, so the shortest answer in bytes wins.
I feel like it would've been much more of a challenge to follow the pattern along the coil. – Magic Octopus Urn – 2017-01-20T14:52:42.303
@carusocomputing you mean the inverse? – MildlyMilquetoast – 2017-01-20T16:47:30.160
http://codegolf.stackexchange.com/a/107531/59376 turns out I didn't understand the challenge as written, that's exactly the challenge ahaha. – Magic Octopus Urn – 2017-01-20T17:00:16.123