Skip to content

Instantly share code, notes, and snippets.

Created January 1, 2015 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/efdb2ac517daeda7ad5b to your computer and use it in GitHub Desktop.
Save anonymous/efdb2ac517daeda7ad5b to your computer and use it in GitHub Desktop.
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