# Repetition of letters [duplicate]

a,b,4,5

And produce an output, which per this example is aaaabbbbb

a,b,4,5 means: the lowercase character "a" is repeated 4 times, and is then followed by the lowercase character "b" repeated 5 times, making the total number of characters 4+5=9

Another example: the input a,B,5,4, should produce the output aaaaaBBBB, which is: the lowercase letter "a" is repeated 5 times, followed by the uppercase letter "B" repeated 4 times.

Some more examples:

Input --> Output

a,b,4,6         --> aaaabbbbbb
a,b,c,1,2,3     --> abbccc
a,e,d,f,g,1,2,3,4,5 --> aeedddffffggggg
A,b,4,5         --> AAAAbbbbb
A,b,C,1,2,3     --> AbbCCC
A,B,c,D,1,2,3,4 --> ABBcccDDDD


Note how the output must have only the required letters, nothing else, except trailing newlines.

The format of the input should be exactly as you see in the above examples, so your code does not have to support any additional formats/styles of the input.

The output must be displayed in a format exactly as the examples show, this means no commas, spaces, etc, separating the letters. Trailing newlines are okay, if you cannot avoid them.

Standard loopholes are disallowed, and the output is case sensitive.

This is , so the shortest code in bytes wins!

• will the numbers always be increasing? – Maltysen Aug 20 '16 at 1:08
• This seems quite similar to Run Length Decoding. – Dennis Aug 20 '16 at 1:13
• @ColdGolf Stricter input/output is a pretty trivial modification to a challenge. – Suever Aug 20 '16 at 1:22
• Will the numbers always be one digit, as in your examples? – Jordan Aug 20 '16 at 2:43
• @ColdGolf can we accept input as a list or list of letter-number pairs? I ask because the language I'm thinking of doesn't do well with string parsing, and it's lists look funny when typed out.... – Socratic Phoenix Aug 20 '16 at 3:54

## 05AB1E, 11 bytes

',¡2äøvy×?


Explanation

',¡             # turn input into a list split at commas
2ä           # divide that list in 2
ø        # zip, turning the list into pairs of [letter, number]
v       # for each pair
y×?   # print letter number of times


Try it online

# Pyth - 14 bytes

Ac2cz\,s*VGsMH


# APL, 26 bytes

{(∊(//)C⎕VFI⍵)/⍵~⎕D,C←','}


Test:

          {(∊(//)C⎕VFI⍵)/⍵~⎕D,C←','}'A,b,C,1,2,3'
AbbCCC


APL has a built-in for this, so all the code is really doing is parsing the string:

      1 2 3/'AbC'
AbbCCC


Explanation:

• ⍵~⎕D,C←',': remove all digits and commas from the input, leaving only the letters. (Since it only has to deal with single letters, this works.)
• ∊(//)C⎕VFI⍵: using the comma as a field separator, get all valid numbers in the input.
• /: replicate each letter by the required amount
• Same basic idea: {(⍎⍵∩c)/⍵~c←⎕D,','} – Adám Aug 28 '16 at 19:31

# Python 2 - 88 bytes

X=map(str,input().split(','))
k=len(X)/2
print''.join(X[i]*int(X[i+k])for i in range(k))


Edited to remove whitespace

• Quoted input is acceptable, so you can do input() instead of raw_input(). Additionally, you can drop the whitespace between print and '', and between ) and for. Be sure to take a look at codegolf.stackexchange.com/q/54/45941 for more golfing suggestions! I've also changed the header to Python 2, because we typically only use "Python" for code that can run under either 2 or 3. Last but certainly not least, welcome to PPCG! – user45941 Aug 20 '16 at 3:01
• idk if it'll be shorter, but chopping in half can also be done through zip(*[iter(foo)]*2) – Maltysen Aug 20 '16 at 3:42

# Python 2, 66 bytes

i=input();l=len(i)/2
print''.join(s*y for s,y in zip(i[:l],i[l:]))


Uses every Python golfer's favourite function, zip(). Takes input with letters in quotes e.g.:

'a','b',4,6


Ideone it!

# PHP, 84 bytes

$b=split(',',$argv[1]);while($i<$n=count($b)/2)echo str_repeat($b[+$i],$b[$n+$i++]);


Takes the input string as the first argument as in php script.php a,B,c,3,2,6.