Skip to content

Instantly share code, notes, and snippets.

@LyricLy
Last active February 19, 2023 11:30
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 LyricLy/000f9133ae7187fb863fc4f388c08069 to your computer and use it in GitHub Desktop.
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.
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