6 kyu

Typing series #3 --> copy and paste

Description:

You are given a string of lowercase letters and spaces that you need to type out. You may notice some square brackets inside the string.

  • If it contains letters, type out the text inside then copy it.
  • If it is empty, paste the copied text
  • If it contains a number, paste the copied text that number of times.

Here are a few examples.

[ten ]ten [3] -> ten ten ten ten ten

[one hundred and ]one, []two, []three -> one hundred and one, one hundred and two, one hundred and three

[100][repeat me][2] -> repeat merepeat merepeat me (pasting nothing 100 times is still nothing)

Notes:

  • Although it is possible, nested loops will not be tested.
  • The number inside the bracket will always be a positive integer (1, 2, 3...).
  • All inputs will be valid (no unclosed brackets, etc)

More examples in the smaple tests.

Good luck!


Check out the rest of the kata in this series!

Regular Expressions

More By Author:

Check out these other kata created by goldenratio161

Stats:

CreatedDec 8, 2023
PublishedDec 12, 2023
Warriors Trained221
Total Skips6
Total Code Submissions266
Total Times Completed96
Python Completions96
Total Stars6
% of votes with a positive feedback rating98% of 33
Total "Very Satisfied" Votes32
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • goldenratio161 Avatar
  • Blind4Basics Avatar
Ad