50
13
Make a program that takes the word you input, and adds that word to the back of itself minus its first letter, then repeats until all letters are gone. For example, cat
would become catatt
, and hello
would become helloellolloloo
.
Input
Any of the 26 letters of the English alphabet. There may be multiple words separated by spaces, and the change should be applied to every word.
Output
The word(s) inputted, with each word put after itself with its first letter missing, and then with its second letter missing, and so on until there are no more letters to add.
More examples:
ill eel
outputs illlll eelell
laser bat
outputs laserasersererr batatt
darth vader
outputs dartharthrththh vaderaderdererr
This is code golf, so the shortest code wins.
Clarification:
You can treat the input or output as a list. You can separate words using newline instead of space. You can add a trailing space to the input.
22honestly, the multiple words thing is kinda annoying. All it does is require a split, apply the function on each word, and then join again. It's also quite debilitating for lots of esolangs which have to check for a space manually – Jo King – 2018-09-18T22:44:39.537
Can I require a trailing space in the input? – Jonathan Frech – 2018-09-18T23:20:17.377
sure, you can require a trailing space – qazwsx – 2018-09-18T23:36:45.303
4Can we take in input as a list of words and output as such? – Quintec – 2018-09-18T23:53:54.370
1yes you can Quintec – qazwsx – 2018-09-19T00:24:51.400
4What length words do you need to handle? – MickyT – 2018-09-19T01:14:47.417
5Is it OK for words to be separated by a newline in the output(instead of a space)? – JayCe – 2018-09-19T01:37:38.937
1Off topic, but FWIW, this is the exact output you would normally get when you type stuff on the new Macbook, the one with the butterfly keyboard. – SeaWarrior404 – 2018-09-19T08:03:41.037
Does it need to handle blank input – u_ndefined – 2018-09-19T08:27:53.283
10
1.
Please update the spec with the new allowances (array I/O, trailing space, etc.)2.
Please inform the existing solutions in case any can save bytes by taking advantage of them. – Shaggy – 2018-09-19T08:36:55.423Can the program take input on separate lines, one word per line? – Doorknob – 2018-09-19T18:57:51.113
Can we assume a word is not longer than the range of the native integer? – NieDzejkob – 2018-09-20T17:14:11.660
yes niedzejkob extra character – qazwsx – 2018-09-20T17:43:48.607
Hello, Welcome to PPCG! If you want to reply to a question asked by a commenter and ensure they're notified, you can use @. Also, as @Shaggy mentioned, make sure to edit the question with this new information to make sure it's always up-to-date. – JayCe – 2018-09-20T18:22:16.443
2@JoKing: so you only want simple puzzles and you're worried that you need 3 bytes more, 1 for splitting, 1 for looping and 1 for joining? Sorry, I implement in C# and I need 200 bytes just for keywords. – Thomas Weller – 2018-09-25T19:52:39.013
You never answered @MickyT's comment, is 9223372036854775807 characters as an upper limit for string length okay? – ბიმო – 2018-10-01T16:33:30.253
@BMO I thought there was a meta consensus that you didn't need to worry about reasonable implementation limits, but finding things again on meta is a black art. – Ørjan Johansen – 2018-10-02T03:47:33.923