Brainfuck Printer

A challenge by MeWhenI avatar MeWhenI

Description

For each line of input of printable ASCII (0x20-0x7e), output a brainfuck program which produces that string. Your score is the sum of the length of your program and the length of the code it would output for “Hello World!”

For example, if one line of the input is ABC you could output +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+.+.

For reference, Brainfuck is played on an infinite tape of 8-bit values extending in both sides with all values starting at 0. The commands are as follows:

  • + increment the current value in the tape, wrapping back to 0 after 255. (*ptr++)
  • - decrement the current value in the tape, wrappeing back to 255 after 0 (*ptr–)
  • > move to the next value on the tape (ptr–)
  • < move to the previous value on the tape (ptr++)
  • [ Jump to past the matching ] if the current value on the tape is 0 (while(*ptr) {)
  • ] Jump to before the matching [ (})
  • . Output the current value on the tape (putchar(*ptr))

Any other characters are ignored.

Leaderboard

Author Total Bytes
#1 MeWhenI avatar MeWhenI 3329