Ctrl K

Bracket Shorthand Decoder

Easy
A stadium scoreboard saves space by sending words in a shorthand string code. The shorthand is glued together from three kinds of pieces, in any order: - G stands for the letter G; - () stands for the letter o; - (al) stands for the two letters al. Decode every piece and return the resulting string, keeping the pieces in their original order.
Example 1
code='(al)()G' → 'aloG'

(al) → al, () → o, G → G; together that is aloG.

Example 2
code='G()()G(al)' → 'GooGal'

Each pair of empty brackets becomes an o: GooGal.

Example 3
code='G' → 'G'
Constraints
  • 1 ≤ len(code) ≤ 100
  • code is made up entirely of the pieces G, () and (al)
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
code='(al)()G'
Expected
'aloG'

Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.