17
1
Rules
The program should receive a string/array of words as input. For each word in the string/array, it will reconstruct the word by taking characters in alternating fashion from the front and back of the word.
12345 678 9 -> 15243 687 9.
It will then rearrange the words in an alternating fashion between the earliest and the latest occurring word in the string.
15243 687 9 -> 15243 9 687
Finally, it will reconstruct the string by placing the spaces, tabs and newlines at the indexes where they were initially located before outputting the result.
12345 678 9-> 15243 687 9 -> 15243 9 687 -> 15243 968 7
Output should be the same datatype as the input.
Standard Loopholes are forbidden
Examples
Input:
The quick brown fox jumps over the lazy dog.
Output:
Teh d.ogq kucil yaz bnrwo tehf xoo rvej supmInput:
The quick brown fox jumps
over the lazy dog.
Output:
Teh d.ogq kucil yaz bnrwo
tehf xoo rvej supmInput:
Aflack
Output:
Akfcla
This is code-golf so shortest code wins
6This feels like a duplicate. I swear I've seen this before. – Addison Crump – 2017-02-07T18:49:17.860
So only tab, space and newline characters are not considered part of a word? – Jonathan Allan – 2017-02-07T18:50:21.497
@JonathanAllan that is correct – fəˈnɛtɪk – 2017-02-07T18:51:41.750
Can we assume ASCII? or Unicode? – MayorMonty – 2017-02-07T22:29:28.267
@MayorMonty You can assume the characters are whichever form makes it easier for you so long as it treats spaces properly. – fəˈnɛtɪk – 2017-02-07T23:20:04.770