Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
decode3[string_] := Module[{spliced, zeroed, levels, sorted, strings},
spliced =
StringReplace[
str, {"[" | "{" | "(" -> -1, "]" | "}" | ")" -> 1, " " -> 0}];
zeroed = spliced /. _String :> 0;
levels = Accumulate[zeroed];
sorted = spliced[[Ordering@levels]];
strings = Cases[sorted, _String]]
decode3["[can {and it(it (mix) up)} look silly]"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.