Skip to content

Instantly share code, notes, and snippets.

@DonaldKellett
Created December 26, 2016 16:26
Show Gist options
  • Save DonaldKellett/f05e27814b1a51284d16a407d85a7ce7 to your computer and use it in GitHub Desktop.
Save DonaldKellett/f05e27814b1a51284d16a407d85a7ce7 to your computer and use it in GitHub Desktop.
Converts Brainfuck code into Boolfuck code with no optimizations performed. All non-command characters are removed.
function brainfuckToBoolfuck(brainfuck) {
return brainfuck.replace(/[^+\-.,<>\[\]]/g, "").split("").map(command => ({
"+": ">[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<",
"-": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]<<<<<<<<<",
"<": "<<<<<<<<<",
">": ">>>>>>>>>",
",": ">,>,>,>,>,>,>,>,<<<<<<<<",
".": ">;>;>;>;>;>;>;>;<<<<<<<<",
"[": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]",
"]": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]"
})[command]).join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment