Skip to main content
deleted 83 characters in body
Source Link
Martin Ender
  • 198.3k
  • 67
  • 455
  • 999

CJam, 9 88 7 bytes

Thanks to jimmy23013 for saving 1 byte.

Sl+ee::*Sl+eee~ 

Test it here.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# ApplyRun-length "repeat"decode. to each pair. [["" "L" "oo" "bbb" "bbbb" "YYYYY"]] ["LoobbbbbbbYYYYY"] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

CJam, 9 8 bytes

Sl+ee::* 

Test it here.

Explanation

Using the LobbY example:

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# Apply "repeat" to each pair. [["" "L" "oo" "bbb" "bbbb" "YYYYY"]] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

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"] 
deleted 248 characters in body
Source Link
Martin Ender
  • 198.3k
  • 67
  • 455
  • 999

CJam, 99 8 bytes

l_eeSl+ee::*.+ 

Test it here.

This also works:Test it here.

Lal+ee::* 

Explanation

Using the LobbY example:

lS e# ReadPush inputspace. ["LobbY"][" "] _l e# DuplicateRead input. [" ["LobbY"" "LobbY"] ee+  e# EnumerateAppend. ["LobbY" [[0 'L] [1[" 'o]LobbY"] ee [2 'b] [3e# 'b]Enumerate. [4 'Y]]] ::* e# Apply "repeat" to each pair. ["LobbY" ["" "o" "bb" "bbb" "YYYY"]] .+ e# Pairwise[[[0 append.' ] [1 'L] [2 'o] [3 'b] [4 'b] [5 'Y]]] ::* e# Apply "repeat" to each [["L"pair.  [["" "L" "oo" "bbb" "bbbb" "YYYYY"]] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

In the alternative solution we prepend an empty string to the input, so that the indices of all the characters in the input are one greater and already get the correct repetition.

CJam, 9 bytes

l_ee::*.+ 

Test it here.

This also works:

Lal+ee::* 

Explanation

Using the LobbY example:

l e# Read input. ["LobbY"] _ e# Duplicate. ["LobbY" "LobbY"] ee e# Enumerate. ["LobbY" [[0 'L] [1 'o] [2 'b] [3 'b] [4 'Y]]] ::* e# Apply "repeat" to each pair. ["LobbY" ["" "o" "bb" "bbb" "YYYY"]] .+ e# Pairwise append. [["L" "oo" "bbb" "bbbb" "YYYYY"]] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

In the alternative solution we prepend an empty string to the input, so that the indices of all the characters in the input are one greater and already get the correct repetition.

CJam, 9 8 bytes

Sl+ee::* 

Test it here.

Explanation

Using the LobbY example:

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# Apply "repeat" to each pair.  [["" "L" "oo" "bbb" "bbbb" "YYYYY"]] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

Source Link
Martin Ender
  • 198.3k
  • 67
  • 455
  • 999

CJam, 9 bytes

l_ee::*.+ 

Test it here.

This also works:

Lal+ee::* 

Explanation

Using the LobbY example:

l e# Read input. ["LobbY"] _ e# Duplicate. ["LobbY" "LobbY"] ee e# Enumerate. ["LobbY" [[0 'L] [1 'o] [2 'b] [3 'b] [4 'Y]]] ::* e# Apply "repeat" to each pair. ["LobbY" ["" "o" "bb" "bbb" "YYYY"]] .+ e# Pairwise append. [["L" "oo" "bbb" "bbbb" "YYYYY"]] 

At the end of the program, the stack is printed implicitly, but without all array and string literal syntax around it so we just get LoobbbbbbbYYYYY as required.

In the alternative solution we prepend an empty string to the input, so that the indices of all the characters in the input are one greater and already get the correct repetition.