-
-
Save LyricLy/000f9133ae7187fb863fc4f388c08069 to your computer and use it in GitHub Desktop.
A transpiler of Bitwise Cyclic Tag to Newbiefuck, a Brainfuck variant with do-while loops instead of while loops.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
program = sys.argv[1] | |
init = sys.argv[2] | |
output = ">>>" | |
output += ">".join("+" * (int(d) + 1) for d in init) | |
output += "<" * (output.count(">") - 3) | |
output += "[" | |
p = 0 | |
while p < len(program): | |
c = program[p] | |
p += 1 | |
if c == "0": | |
output += "[-]>" | |
elif c == "1": | |
to_push = int(program[p]) + 1 | |
p += 1 | |
output += f">[-<<<+>>>]<[-<+<<+>>>]<[->+<]>[[>]{to_push*'+'}[<]>-]>{to_push*'-'}<<<<[->>>+<<<]>[->>>+<<<]>>" | |
print(output + "]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment