Your task is to write a program or function which takes a pure brainflak program as input (assume it contains only balanced ()[]{}<>
), and output a visually mirrored copy of it.
If you reversed a brainflak program as a string, say ({}())
(add one to an input), you would get ))(}{(
, which is not valid.
Instead, you should mirror it, by reversing the direction of the parentheses/brackets/braces/angle-brackets, like what you would see if the program was placed in front of a mirror: ((){})
.
Test cases (???
means anything is okay):
() -> ()
({}[{}]) -> ([{}]{})
()[] -> []()
<(){}[]> -> <[]{}()>
([{<()[]{}<>>}]) ->([{<<>{}[]()>}])
(a) -> ???
{> -> ???
))(}{( -> ???
()↵[] -> ???
This is a code golf challenge, shortest answer per language wins.
([{<()[]{}<>>}])
or similarly convoluted? \$\endgroup\$(){}[]<>
and is perfectly balanced. \$\endgroup\$