Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Challenges
Parent

Repeat the characters

+4
−0

Given a string and a non-negative integer $n$, output a new string in which each character is repeated $n$ times.

Test cases:

"abc", 1    -> "abc"
"Hello", 0  -> ""
"double", 2 -> "ddoouubbllee"
"Hi", 4     -> "HHHHiiii"
"", 20      -> ""
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+2
−0

jq, 32 27 bytes

-5 bytes (thank you Razetime)

.n as$n|.s/""|map(.*$n)|add

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

2 comment threads

18 bytes: [Try it online!](https://tio.run/##yyr8/z9aQ69YX0lJMzpWSy8vtiYxJeX//2ouBQWlYiUrJY/UnJx8hfD8... (1 comment)
you can use `add` in place of join. (1 comment)

Comments on Repeat the characters

you can use `add` in place of join.
Razetime‭ wrote about 1 month ago:

you can use add in place of join.

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!