Given a string consisting of ()[]{}
, print the paired brackets in the same order as they appear in the string.
Any opening bracket ([{
can be paired with any closing bracket )]}
.
For example:
({()[}]]
returns:
(], {], (), [}
Rules
- A string consisting of
()[]{}
should be received as the input - The bracket-pairs should be returned as a list, or separated by a distinct character (or nothing), etc.
- The bracket-pairs should be in the same order as the starting brackets in the string
- The brackets will be balanced, i.e. the number of opening brackets and the number of the closing brackets will be the same
- Default Loopholes apply
- This is code-golf, so the shortest code wins!
Examples
[In]: ()
[Out]: ()
[In]: (}{]
[Out]: (}, {]
[In]: ([{}])
[Out]: (), [], {}
[In]: {]([(}]{)}
[Out]: {], (}, [], (}, {)