Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
for c in s:print(end=[c,c*n][i%n<1]);i+=1
For one byte less (57), I coded a lambda, however similar answers have already been posted by other users:
lambda s,n:''.join([c,c*n][i%n<1]for i,c in enumerate(s))
Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
for c in s:print(end=[c,c*n][i%n<1]);i+=1
Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
for c in s:print(end=[c,c*n][i%n<1]);i+=1
For one byte less (57), I coded a lambda, however similar answers have already been posted by other users:
lambda s,n:''.join([c,c*n][i%n<1]for i,c in enumerate(s))
Python 3, 5758 bytes
The non recursive approach!Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite not being recursivea full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
lambdadef f(s,n:''.join([c,c*n][i%n<1]fori=0):
i,for c in enumerate(s):print(end=[c,c*n][i%n<1]);i+=1
Python 3, 57 bytes
The non recursive approach!
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite not being recursive.
lambda s,n:''.join([c,c*n][i%n<1]for i,c in enumerate(s))
Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
for c in s:print(end=[c,c*n][i%n<1]);i+=1
Python 3, 5857 bytes
Working on golfing it down.The non recursive approach!
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUTbeing recursive.
deflambda f(s,n,i=0):
for''.join([c,c*n][i%n<1]for i,c in s:printenumerate(end=[c,c*n][i%n<1]s);i+=1)
My best attempt at a recursive lambda ended up at 57 bytes (however, others have already posted similar, shorter, lambdas)Try it online!
f=lambda s,n,i=0:s[i:]and[1,n][i%n<1]*s[i]+f(s,n,i+1)or''
Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
for c in s:print(end=[c,c*n][i%n<1]);i+=1
My best attempt at a recursive lambda ended up at 57 bytes (however, others have already posted similar, shorter, lambdas)
f=lambda s,n,i=0:s[i:]and[1,n][i%n<1]*s[i]+f(s,n,i+1)or''
Python 3, 57 bytes
The non recursive approach!
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite not being recursive.
lambda s,n:''.join([c,c*n][i%n<1]for i,c in enumerate(s))