33
5
Nice verb there, in the title.
Write a program that given an input string, will "elasticize" this string and output the result. Elasticizing a string is done as follows:
The first character is shown once. The second character is shown twice. The third character is shown thrice, and so on.
As you can see, the amount of duplications of a certain character is related to the character's index as opposed to its previous occurrences in the string.
You can expect to receive only printable ASCII characters. Based off the following link, these characters have decimal values 32-126.
Examples:
Why: Whhyyy
SKype: SKKyyyppppeeeee
LobbY: LoobbbbbbbYYYYY
(Note how there are 7 b's since the first b is shown 3 times and the second b is shown 4 times, making a total of 7 b's).
A and B: A aaannnnddddd BBBBBBB
Shortest bytes wins :)
2
That seems to disagree with "no support for whitespace is needed, other than the space character". Should the output be the same as the input then? (Two one letter words?) Also note we have a nice place called the Sandbox where you can put challenges for people to give you feedback before posting them.
– FryAmTheEggman – 2016-06-20T19:50:56.373FryAmTheEggman your assumption is valid. @TimmyD I realize where I was unclear, you may end up with strings separated my multiple spaces, as seen in the example FryAmTheEggman posted. – Mario Ishac – 2016-06-20T19:52:24.560
I'm assuming that the shortest code wins? ;) – Adnan – 2016-06-20T19:54:58.277
@Adnan Yep, though I'm not sure if I should mark the answer with the shorted program as accepted, as certain languages are made for golfing purposes unlike others. – Mario Ishac – 2016-06-20T19:56:13.103
And here I was ready to be clever and start making strings more expensive as more of them were allocated... – J... – 2016-06-21T01:15:10.597
2
Related: 1, 2
– Sp3000 – 2016-06-21T03:36:41.000Need it be a full program, or simply a function? – None – 2016-06-22T22:08:11.400
@Zymus Based on the answers, I would say function. – Mario Ishac – 2016-06-23T02:07:16.543