File size: 758 Bytes
76a33ae
 
7fc9433
a231aae
 
 
4b1580c
 
 
 
76a33ae
 
a231aae
7fc9433
a231aae
 
 
 
 
7fc9433
76a33ae
7fc9433
a231aae
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr

def text_to_brainfck(text):
    brainfuck_code = ""
    for char in text:
        ascii_value = ord(char)
        # Add '[' and ']' for loops
        if ascii_value > 0:
            brainfuck_code += "[" + "+" * ascii_value + "]"
        brainfuck_code += "."
    return brainfuck_code

with gr.Blocks() as demo:
    gr.Markdown("## Text to Brainfck Code Translator")
    with gr.Row():
        with gr.Column():
            text_input = gr.Textbox(label="Input Text", lines=4)
            translate_button = gr.Button("Translate")
        with gr.Column():
            brainfck_output = gr.Textbox(label="Brainfck Code", lines=10)

    translate_button.click(text_to_brainfck, inputs=text_input, outputs=brainfck_output)

demo.launch()