| import gradio as gr |
|
|
| def text_to_brainfck(text): |
| brainfuck_code = "" |
| for char in text: |
| ascii_value = ord(char) |
| |
| 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() |
|
|