Normal brackets (()
,[]
,<>
and {}
) are nice and unambiguous, however someone thought it would be a good idea to use non bracket characters as brackets. These characters, |
and "
, are ambiguous. For example does
""""
correspond to
(())
or
()()
It is impossible to tell.
Things start to get interesting when you mix types of ambiguous brackets, for example
"|""||""|"
Could be any of the following
([(([]))]),([()[]()]),([()][()])
Task
Your task is to take a string made of ambiguous characters and output all the possible balanced strings the author could have intended.
More concretely you output all balanced strings that can be made replacing |
with either [
or ]
and "
with either (
or )
. You should not output any balanced string twice.
IO
As input you should take a string consisting of |
and "
. If you would like to select two distinct characters other than |
and "
to serve as replacements you may do so. You should output a container of balanced strings. You may choose to replace []
and ()
in the output with any other two bracket pairs (()
,[]
,<>
or {}
) you wish. Your output format should be consistent across runs.
Scoring
This is code-golf so answers will be scored in bytes with fewer bytes being better.
Test cases
"" -> ["()"]
"|"| -> []
||| -> []
"""" -> ["(())","()()"]
""|| -> ["()[]"]
"|"||"|" -> ["([([])])"]
"|""||""|" -> ["([(([]))])","([()[]()])","([()][()])"]