I just wanted to mess with my friend a little and wanted to text him in Brainfuck. Being a coder like me, I decided, why not just write a quick script to translate it for me?
Considering that most characters that I will be using in a regular English chat will be between 0-127, the algorithm will take the nearest factor of ten. Then it will add the result of the char number modulus that factor. Then I will translate that into Brainfuck.
I am ready to take all criticism so please give your opinion. Also, please test in and find any case where my algorithm will fail.
def letter_to_brainfuck(letter):
num = ord(letter)
return '+'*int(num / 10) + '[>++++++++++<-]>' + '+'*(num % 10)
def brainfuck_print(letter_list):
return ''.join([i +'.>\n' for i in letter_list])
print(brainfuck_print([letter_to_brainfuck(i) for i in list(input())]))