Write a program or function that duplicates letters in a word, so that all the duplicated letters arranged in order would form the input array.
For example:
Input: abcdefghi, abc
Output: aabbccdefghi
Here is my shot at it in lua (76 bytes):
function f(x,y)for i=1,#x do g=y:sub(i,i);x=x:gsub(g,g..g,1)end print(x)endMy question is, can this code be golfed down anymore/is there a different way to approach this that is shorter?
Thanks!












