All pastes #966220 Raw Copy code Copy link Edit

Brainf*ck to Unary converter in

public python v1 · immutable
#966220 ·published 2008-04-01 16:13 UTC
rendered paste body
# Brainfuck to Unary converter(well, in part) v.0.1def unaryconvert():    source = raw_input(">") #prompt for entering code    z = "1" #make sure output starts with a 1    for y in range(0, len(source)):        code_input = source[(y):(y+1)] #process a single character at a time        if code_input == ">": #elif sequence to add binary numbers            z += "000"        elif code_input == "<":            z += "001"        elif code_input == "+":            z += "010"        elif code_input == "-":            z += "011"        elif code_input == ".":            z += "100"        elif code_input == ",":            z += "101"        elif code_input == "[":            z += "110"        elif code_input == "]":            z += "111"        else:            break #if a non-BF character is encountered, stop    print z #print the binary numberif __name__ == "__main__":    unaryconvert()