6 kyu
Chunky strings
54 of 107Paul Robertson
Description:
This kata concerns a string composed of 'chunks'.
A chunk is either:
- A single alphabetic character
or:
- Two chunks enclosed in square brackets
[
and]
A 'chunky string' is a string consisting of exactly one chunk. Here are some examples of chunky strings:
'x'
'[xy]'
'[x[yy]]'
'[[xy]y]'
'[[ab][ab]]'
'[c[o[d[e[w[a[rs]]]]]]]'
For this task you will be given a valid chunky string from which all the closing brackets have been removed. You must restore the brackets and return the original valid chunky string.
For example:
Input Restored String
'x' 'x'
'[xy' '[xy]'
'[x[yy' '[x[yy]]'
'[[xyy' '[[xy]y]'
'[[ab[ab' '[[ab][ab]]'
'[c[o[d[e[w[a[rs' '[c[o[d[e[w[a[rs]]]]]]]'
In the tests all input strings will be valid chunky strings (with closing brackets removed).
Strings
Recursion
Similar Kata:
Stats:
Created | Aug 31, 2024 |
Published | Aug 31, 2024 |
Warriors Trained | 716 |
Total Skips | 27 |
Total Code Submissions | 952 |
Total Times Completed | 107 |
Python Completions | 54 |
JavaScript Completions | 46 |
C++ Completions | 26 |
Haskell Completions | 7 |
Total Stars | 23 |
% of votes with a positive feedback rating | 100% of 27 |
Total "Very Satisfied" Votes | 27 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |