g | x | w | all
Bytes Lang Time Link
038AWK250521T175503Zxrs
nanPerl 5250521T201232ZXcali
003Thunno 2 J230613T184042ZThe Thon
054C clang220821T160013Zc--
038Zsh210216T202914Zpxeger
006Brachylog v2230128T114450ZUnrelate
nan230128T101855ZThe Thon
044Arturo230128T100218Zchunes
033><> Fish221116T164622Zmousetai
003Japt m221116T164544ZShaggy
014Pip221116T161642ZBaby_Boy
069Prolog SWI220827T203009ZnaffetS
067Kustom220826T140027ZLeaf
053C# Visual C# Interactive Compiler220823T042144ZIvan Nee
010Burlesque220822T190858ZDeathInc
002Jelly220822T181632ZBaby_Boy
008BQN220821T201543ZDLosc
002Vyxal s220821T072925Ztybocopp
032Knight220821T040526ZSampersa
047Dart220821T033148Zuser1142
042brev220820T083419ZSandra
002Jelly170315T123347ZErik the
00205AB1E191218T110207ZKevin Cr
005APL dzaima/APL160620T213212ZAdá
050R180831T191619ZSumner18
136Java170316T211113Zuser6333
058Javascript170316T055609ZKushal B
006Siliconnoncompeting160630T135455Zm654
077C160622T220604Zhomersim
022Retina160621T074300ZMartin E
015Brainfuck160621T034037ZSp3000
086Clojure160622T092344Zcliffroo
084C160621T202040Zjqkul
121Java160620T200327Zuser8397
041Javascript ES6160620T201420ZDendrobi
068PHP160621T143822ZSimon
125Oracle SQL 11.2160621T122421ZJeto
082LINQPad w/ C#160621T111319ZSør
046Mathematica160621T100006ZLLlAMnYP
032Julia160621T092336ZGlen O
097TSQL160621T084037Zt-clause
007CJam160620T204306ZMartin E
075VBA160621T065833ZJoffan
2747Python 2.7 47 Bytes160621T065316ZSwadhika
004Pyke160621T060905ZBlue
029Ruby160621T043013ZValue In
034Julia160621T041253ZDennis
019Perl 6160621T032425ZBrad Gil
039Python160621T012438ZDennis
040Python160621T010758Zxnor
014K/Kona160621T001051ZSimon Ma
029Haskell160620T195535Znimi
016Perl160620T232341ZDoorknob
039Javascript ES6160620T212358Znderscor
062Retina160620T220458Zmbomb007
004J160620T211628Zmiles
023MATLAB160620T211113ZSuever
005MATL160620T210657ZSuever
013Brachylog160620T204400ZFatalize
076PHP160620T210346ZInaScuff
081C#160620T204831ZScifiDea
003Jelly160620T200838ZAdnan
047Python 3160620T200625Zjqkul
045MATLAB160620T201100Zflawr
005Pyth160620T195954ZMaltysen
007Actually160620T200414Zuser4594
00605AB1E160620T200106ZEmigna
008APL160620T195249Zmarinus
036PowerShell v2+160620T194920ZAdmBorkB

AWK, 39 38 bytes

{for(;i++<NF;)for(j=0;j++<i;)printf$i}

Attempt This Online!

Perl 5, 14 + 1 (-p) = 15 bytes

s/./$&x++$i/ge

Try it online!

Thunno 2 J, 3 bytes

dż×

Attempt This Online!

Explanation

dż×  # Implicit input           ->  "Why"
d    # Split into characters    ->  ["W","h","y"]
 ż   # Length range             ->  ["W","h","y"]  [1,2,3]
  ×  # Multiply together        ->  ["W","hh","yyy"]
     # Implicit output, joined  ->  "Whhyyy"

C (clang), 54 bytes

i;c;main(j){for(;j=j-1?:read(0,&c,1)*++i;)putchar(c);}

Try it online!

How it works

i;            // declares a zero initialized int
main(j){      // j := argc (should be 1, program called with no arguments)
 for(;j=j-1?: // if (j > 1) j = j - 1, otherwise...
 read(0,&c,1) // try to read 1 byte, return number of bytes read (0 on EOF or 1)
 *++i;)       // increment i, j = read? * i (stopping on EOF)
  putchar(c); // write to stdout
}

C (clang), 51 bytes

i,j;f(*s){for(i=0;*s;s++)for(j=++i;j--;)printf(s);}

This function takes a wide-character string as input and works in the same way as the full program.

Try it online!

Zsh, 38 bytes

for i (${(s::)@});repeat ++n printf $i

Try it online!

-8 bytes thanks to roblogic

Brachylog v2, 6 bytes

i₁j₎w⊥

Try it online!

Half-port of Fatalize's v1 answer.

i₁        Choose a pair [element, 1-index] from the input.
  j₎      Replicate the element by its index.
    w     Print the result with no trailing newline.
     ⊥    Backtrack.

Thunno J, \$9\log_{256}(96)\approx\$ 7.41 bytes

DLR1+ZZ.P

Attempt This Online!

Explanation

DLR1+ZZ.P  # Implicit input
D          # Duplicate
 LR        # Push range(0, len(input))
   1+      # Add one to each
     ZZ    # Zip with the input
       .P  # Product of each pair
           # Implicit output, joined by J flag 

Arturo, 44 bytes

$[s][i:0join map split s'c[i:i+1repeat c i]]

Try it

><> (Fish), 33 bytes

1:i:0(?^$:?v~~1+00.
.!02o:$;!-1<|

Try the animated version

enter image description here

Basically if the counter is 0 skip to the second :, otherwise the first :. Properly adjust the counters.

Japt -m, 3 bytes

+pV

Try it here

Pip, 14 bytes

Fi,#aOa@iXi+1x

Try It Online!

Prolog (SWI), 69 bytes

S*O:-append(H,[T],S),maplist([_,Y]>>(Y=T),S,R),H*Y,append(Y,R,O);O=S.

Try it online!

I feel like this should be shorter...

Kustom, 67 bytes

This makes use of the fact that an undefined global variable works as empty string. The extra byte is for the name of the defined global variable.

$fl(1,tc(len,gv(n)),"i+1","tc(lpad,gv(x),i,tc(cut,gv(n),i-1,1))")$

Sort of ungolfed:

$fl(
  1,
  tc(len, gv(input)),
  "i + 1",
  "tc(
    lpad,
    gv(undefined),
    i,
    tc(
      cut,
      gv(input),
      i - 1,
      1
    )
  )"
)$

C# (Visual C# Interactive Compiler), 53 bytes

a=>string.Concat(a.Select((c,i)=>new@String(c,i+1)));

Try it online!

Burlesque, 10 bytes

{+..*}wi\[

Try it online!

{
 +. # Increment
 .* # Repeat
}wi # Apply with 0-index
\[  # Concatenate

Jelly, 2 bytes

xJ

Try it online!

BQN, 9 8 bytes

⊢/˜1+↕∘≠

Anonymous tacit function. Try it at BQN online!

Explanation

⊢/˜1+↕∘≠
       ≠  Length of argument
     ↕∘   Range
   1+     Add 1 to each, making it an inclusive range from 1 to the length
 /˜       Replicate that many times the elements of
⊢         The original input

Vyxal s, 2 bytes

Þż

Try it online, or see a 3 byte flagless version

Knight, 33 32 bytes

;=i!=sP;W<iLsO+*Gs iT=i+1i"\"O""

Try it online!

expanded:

; = i ! = s PROMPT
; WHILE < i LENGTH s
    : OUTPUT
        +
            * (GET s i TRUE) (= i + 1 i)
        "\" # so no trailing newline
: OUTPUT "" # now output the trailing newline

-1 did =i! instead of ;=iF

Dart, 47 bytes

f(s,[c=0])=>s.split("").map((i)=>i*++c).join();

Try it online!

brev, 42 bytes

(as-list flatten(over(make-list(+ i 1)x)))

Jelly, 2 bytes

xJ

Try it online!

05AB1E, 2 bytes

ƶJ

Try it online or verify all test cases.

Explanation:

ƶ   # Multiply each character in the (implicit) input-string by its 1-based index
 J  # Join the list of substrings together to a single string
    # (after which the result is output implicitly)

APL (dzaima/APL), 6 5 bytes

⍳∘≢⌿⊢

Try it online!

⍳∘≢ enumeration of the argument... (indices of its length)
replicates the elements of...
the unmodified argument

R, 83 50 bytes

-23 Thanks to Giuseppe, though he used essentially an entire new method altogether

function(s)intToUtf8(rep(utf8ToInt(s),1:nchar(s)))

My original post:

function(s){r="";for(i in 1:nchar(s))r=paste0(r,strrep(el(strsplit(s,""))[i],i));r}

Try it online!

I feel like there's definitely a better way to do this, but with my new knowledge of a few functions in R, this is my approach.

Java, 136 bytes

enum b{;public static void main(String[]a){int i=0,j=0;for(;i<a[0].length();i++){for(;j<i+1;j++)System.out.print(a[0].charAt(i));j=0;}}}

Takes input as program arguments.

Ungolfed with comments:

enum b {;
    public static void main(String[]a) {
        int i=0, j=0;                               // Init counters
        for (; i<a[0].length(); i++) {              // For each characters in string
            for (; j < i + 1; j++)                  // Loop from 0 to i
                System.out.print(a[0].charAt(i));   // Print character at i
            j=0;                                    // Reset j
        }
    }
}

Javascript, 58 bytes

e=a=>(Array.from(a).map((e,i)=>(e).repeat(i+1))).join("");

Silicon(non-competing), 6 bytes

(This language is exactly the same age as this challenge, but I added some useful commands right after I saw it, so non-competing I think.)

biSÚÿj

Silicon uses CP037, which is a 255-bit codepage.

Explanation:

b        Push a space
i        Input
S        Split
Ú        Enumerate
ÿ        Replicate each list item n times
j        Join

C, 77 bytes

Not much room for golfing here. If only there were a string repeat operator.

i;main(j){char s[999];gets(s);for(;s[i];i++)for(j=0;j<=i;j++)putchar(s[i]);}

Try it online! http://ideone.com/UliJfD

Retina, 22 bytes

Byte count assumes ISO 8859-1 encoding.

.
$&$.`$*·
+`(.)·
$1$1

Try it online!

Basically, we insert the right amount of · as placeholders between the characters (since these extended ASCII characters can't appear in the input), then fill them up with the adjacent character in the second stage.

Brainfuck, 15 bytes

,[>+[->+<<.>],]

Pretty straightforward implementation, shifting the memory space by 1 for each input char. Requires an interpreter that gives 0 on EOF, and 32-bit/arbitrary precision cells for inputs longer than 255 chars.

Try it online! (Note: TIO uses 8-bit cells)

Clojure, 86 bytes

(fn[s](apply str(mapcat #(repeat(+(nth % 1)1)(nth % 0))(map list s(range(count s))))))

Well, nearly beat C. Create a list of pairs (symbol, its position), then repeat each symbol given number of times and flatten the result list and concatenate the list into one string.

See it here: https://ideone.com/uQNar2

C, 84 bytes

main(c,v,i,j)char**v;{for(i=0;i<strlen(v[1]);++i)for(j=0;j<=i;++j)putchar(v[1][i]);}

This should compile on gcc with no flags. Input is taken through the first command-line argument. E.g.

$ ./elasticize Why
Whhyyy
$ ./elasticize SKype
SKKyyyppppeeeee
$ ./elasticize LobbY
LoobbbbbbbYYYYY
$ ./elasticize A and B
A  aaannnnddddd      BBBBBBB

Ungolfed:

int main(int argc, char** argv) {
    int i, j;
    for(i = 0; i < strlen(argv[1]); ++i) {
        for(j = 0; j <= i; ++j) {
            putchar(v[1][i]);
        }
    }
}

Java, 158 121 bytes

Saved a whopping 37 bytes thanks to Kevin Cruijssen!

interface a{static void main(String[]A){int b=0,B;for(char c:A[0].toCharArray())for(B=b+++2;--B>0;)System.out.print(c);}}

As a bonus, this program can handle all Unicode characters in the existence, including the control characters located at the very end of Basic Multilingual Plane.

Javascript ES6, 42 41 bytes

s=>[,...s].map((e,i)=>e.repeat(i)).join``

Example runs:

f=s=>[,...s].map((e,i)=>e.repeat(i)).join``

f("Why")   => "Whhyyy"
f("SKype") => "SKKyyyppppeeeee"
f("LobbY") => "LoobbbbbbbYYYYY"

PHP, 68 bytes

<?php foreach(str_split($argv[1])as$i=>$a)echo str_repeat($a,$i+1);

Oracle SQL 11.2, 125 bytes

SELECT LISTAGG(SUBSTR(RPAD(' ',LEVEL+1,SUBSTR(:1,LEVEL,1)),2))WITHIN GROUP(ORDER BY 1)FROM DUAL CONNECT BY LEVEL<=LENGTH(:1);

LINQPad w/ C#, 82 bytes

void m(string s){Console.Write(s.SelectMany((x,i)=>new string(x,++i)).ToArray());}

Single output operation.

Mathematica, 46 bytes

""<>Table@@@(#^Range@Length@#&@Characters[#])&

Unnamed function. Takes the characters of the input string and raises them to the power of their position in the string (i.e. "abc" becomes {"a"^1, "b"^2, "c"^3}). Yes, MMA don't give a shit 'bout types :-)

The FullForm of the above list elements is Power["a", 1], etc.
Table@@@ acts on the list, replacing the head of each element (in this case Power) with Table.
Results in {Table["a"], Table["b", 2], Table["c", 3]} (because "a"^1 -> "a").
This evaluates to {"a", {"b", "b"}, {"c", "c", "c"}} Finally the infix concatenation operator <> concatenates this with the empty string.

I exploited the fact that Power is Listable, i.e. it automatically threads over corresponding elements of lists, but not orderless (because "a" + 1 would evaluate to Plus[1, "a"]).

Julia, 32 bytes

!s=join(split(s[k=1:end],"").^k)

Unlike Dennis's solution, this is not recursive. split with argument "" separates the string into an array of strings of length 1. The [k=1:end] is a trick to create a range from 1 to the number of characters in the string, and this range is used to concatenate n copies of the n-th character. join then recombines the array of strings into a single string, in order.

Usage example: !"SKype"

TSQL, 97 bytes

Golfed:

DECLARE @x varchar(max)='Lobby'
DECLARE @ int=LEN(@x)WHILE @>0SELECT
@x=STUFF(@x,@,1,REPLICATE(SUBSTRING(@x,@,1),@)),@-=1PRINT @x

Ungolfed:

DECLARE @x varchar(max)='Lobby'

DECLARE @ int=LEN(@x)
WHILE @>0
  SELECT 
    @x=STUFF(@x,@,1,REPLICATE(SUBSTRING(@x,@,1),@)),
    @-=1

PRINT @x

Try it online

CJam, 9 8 7 bytes

Thanks to jimmy23013 for saving 1 byte.

Sl+eee~

Test it here.

Explanation

Using the LobbY example:

                                      Stack:
S    e# Push space.                   [" "]
l    e# Read input.                   [" " "LobbY"]
+    e# Append.                       [" LobbY"]
ee   e# Enumerate.                    [[[0 ' ] [1 'L] [2 'o] [3 'b] [4 'b] [5 'Y]]]
e~   e# Run-length decode.            ["LoobbbbbbbYYYYY"]

VBA, 75 bytes

Function e(s):For a=1 To Len(s):e=e &String(a,Mid(s,a,1)):Next:End Function

Call as e.g. a user function in a spreadsheet.

=e(A1)

┌─────────┬───────────────┐
│   SKype │SKKyyyppppeeeee│
└─────────┴───────────────┘

It truncates if you feed it its own output a few times :-).

Python 2.7 - 47 Bytes

''.join([s[i-1]*i for i in range(1, len(s)+1)])

where 's' is the given string Output:

welcome: weelllccccooooommmmmmeeeeeee
00004:   000000000044444
Why:     Whhyyy
SKype:   SKKyyyppppeeeee
A and B: A  aaannnnddddd      BBBBBBB

Pyke, 4 bytes

Foh*

Try it here!

Ruby, 29 bytes

Try it online

->s{i=0;s.gsub(/./){$&*i+=1}}

Julia, 34 bytes

!s=s>""?!s[1:(e=end)-1]*s[e:e]^e:s

Try it online!

Perl 6,  22 20  19 bytes

{S:g/(.)/{$0 x$/.to}/}
{S:g[(.)]=$0 x$/.to}
{[~] .comb Zx 1..*}

Explanation:

{          # implicit parameter $_
  [~]      # string concatenate the following list
    .comb  # the NFG characters from $_
    Z[x]   # zip combined using the string repetition operator
    1 .. * # 1 to infinity
}

Python, 39 bytes

f=lambda s:s and f(s[:-1])+s[-1]*len(s)

Test it on Ideone.

Python, 40 bytes

f=lambda s,i=1:s and s[0]*i+f(s[1:],i+1)

K/Kona, 14 bytes

{,/(1+!#x)#'x}

Usage:

k){,/(1+!#x)#'x}"A and B"
"A  aaannnnddddd      BBBBBBB"

Haskell, 29 bytes

concat.zipWith replicate[1..]

Usage example: concat.zipWith replicate[1..] $ "SKype" -> "SKKyyyppppeeeee".

replicate n c makes n copies of c and concat makes a single list out of all the sublists.

Perl, 16 bytes

s/./$&x$+[0]/ge

+1 byte for the -p flag.

s/./        /    find every character
             g   globally
              e  and replace with the eval'd result of
    $&           the matched string
      x          repeated
       $+[0]     by the index of the character after the match

Javascript ES6, 39 bytes

x=>x.replace(/./g,(y,i)=>y+y.repeat(i))

Same length, but more fun:

x=>x.replace(i=/./g,y=>y.repeat(i=-~i))

Snippet demo:

f= x=>x.replace(/./g,(y,i)=>y+y.repeat(i))
run.onclick=_=>output.textContent=f(input.value)
<input id="input" value="SKype">
<button id="run">Go</button>
<pre id="output"></pre>

Retina, 62 bytes

It wasn't as easy or short as I thought it'd be. Note that the code contains no spaces. They are all tabs (which are rendered incorrectly here), and the last line is blank.

.*
$0¶ ¶
{+`^(.)(.*)¶    (.*¶.*)
$1$2    ¶$3$1
(   +)¶
¶   $1
}`^.

    |¶

Try it online

J, 4 bytes

#~#\

Usage

   f =: #~#\
   f 'Why'
Whhyyy
   f 'SKype'
SKKyyyppppeeeee
   f 'LobbY'
LoobbbbbbbYYYYY
   f 'A and B'
A  aaannnnddddd      BBBBBBB

Explanation

#~#\  Input: s
  #\  Computes the length of each prefix of s
      This forms the range [1, 2, ..., len(s)]
#~    For each value in the range, copy the character at the
      corresponding index that many times
      Return the created string

MATLAB, 23 bytes

@(x)repelem(x,1:nnz(x))

Creates an anonymous function ans that can be called using ans('stringtoelacticize')

MATL, 5 bytes

tn:Y"

Try it Online

Explanation

    % Implictly grab input as a string
tn  % Duplicate and compute the length (N)
:   % Create an array from [1...N]
Y"  % Perform run-length decoding to elacticize the string
    % Implicitly display the result

Brachylog, 13 bytes

:ImC,0:Ie,Cw\

This prints the result to STDOUT.

Explanation

This is a good example of exploiting backtracking to loop.

:ImC            C is the Ith character of the Input
    ,
     0:Ie       Unify an implicit variable with an integer between 0 and I
         ,
          Cw    Write C to STDOUT
            \   False, trigger backtracking. It will go back to 0:Ie and unify the implicit
                variable with another integer, until all integers were used. After that, it
                will backtrack to :ImC and unify I and C with the next character.

PHP, 76 bytes

I'm sure this can be improved...

<?php for($i=0;$i<strlen($argv[1]);$i++)echo str_repeat($argv[1]{$i},$i+1);

Run from command line:

$ php [file] "Testing"

C#, 81 Bytes

void f(string s){for(int i=0;i<s.Length;i++)Console.Write(new String(s[i],i+1));}

Jelly, 3 bytes

Code:

ĖP€

Explanation:

Ė     # Enumerate.
 P€   # Product of each.
      # Implicit joining of everything.

Uses the Jelly encoding. Try it online!.

Python 3, 48 47 bytes

Thanks to mego for saving a byte with the -~i trick.

lambda s:''.join(c*-~i for i,c in enumerate(s))

This is mostly self-explanatory. One thing for those not versed in Python: The * operator is overloaded to act like Perl's x operator, repeating its string argument the number of times specified by its numeric argument. E.g. 'foo' * 3 == 'foofoofoo'

MATLAB, 45 bytes

g=@(m)sort(m(m>0));@(s)s(g(hankel(1:nnz(s))))

Explanation: The key is hankel, which produces a Hankel matrix of a given vector. From this matrix, we can extract a vector of indices, which defines which character of the string is at which position in the output. E.g. hankel(1:4) produces following matrix:

 1  2  3  4
 2  3  4  0
 3  4  0  0
 4  0  0  0

From this matrix we can extrac the vector 1,2,2,3,3,3,4,4,4,4,4. This vector allows us to output the first character of the string once, the second one twice e.t.c.

Pyth - 5 bytes

1 byte saved thanks to @FryAmTheEggman.

s*VSl

Test Suite.

Actually, 7 bytes

' +ñ♂πΣ

Try it online!

Explanation:

' +ñ♂πΣ
' +      prepend a space
   ñ     enumerate ("abc" -> [[0, 'a'], [1, 'b'], [2, 'c']])
    ♂π   map: for each character, repeat it n times
      Σ  concatenate

05AB1E, 6 bytes

vN>Fy?

Explained

v       # for each char in string
 N>F    # index+1 number of times do
    y?  # print current char

Try it online

APL (8)

{⍵/⍨⍳⍴⍵}

I.e.:

      {⍵/⍨⍳⍴⍵} ¨  'Why' 'SKype' 'LobbY'
┌──────┬───────────────┬───────────────┐
│Whhyyy│SKKyyyppppeeeee│LoobbbbbbbYYYYY│
└──────┴───────────────┴───────────────┘

Explanation:

PowerShell v2+, 36 bytes

-join([char[]]$args[0]|%{"$_"*++$i})

Takes input $args[0], explicitly casts it as a char array, sends that into a loop |%{...}. Each iteration we take the current letter/character "$_" and use the * overloaded operator to concatenate the string pre-incremented $i times. The result of each loop iteration is encapsulated in parens to form an array and then -joined together to form a string. That string is left on the pipeline and output is implicit.

Examples

PS C:\Tools\Scripts\golfing> .\elasticize-a-word.ps1 Why
Whhyyy

PS C:\Tools\Scripts\golfing> .\elasticize-a-word.ps1 SKype
SKKyyyppppeeeee

PS C:\Tools\Scripts\golfing> .\elasticize-a-word.ps1 LobbY
LoobbbbbbbYYYYY

PS C:\Tools\Scripts\golfing> .\elasticize-a-word.ps1 'a b'
a  bbb