Now print “damned” in Brainfuck, and let’s play codegolf.
http://www.iamcal.com/misc/bf_debug/ Debugger to help you visualize what’s going on. The first brainfuck works by incrementing the first cell to 10, then the loop increments the second cell to 100 and the 3rd cell to 110, and the <<- decrements the loop “counter”, which is held by the first cell.
At the end of the loop we should have . Everything after the loop just increments or decrements to the appropriate ascii decimal value and outputs to stdout.
http://www.asciitable.com/ The second one works by first decrementing the value of the first cell, which is 0; hopefully the bf interpreter will wrap around to 255. Not all bf interpreters do this; https://apps.ubuntu.com/cat/applications/saucy/bf/ does but http://swapped.cc/#!/bff doesn’t.
Since the ascii decimal codes of the letters d, m, n, e, d are all in between 100 and 110 (a is 97), the shortest way I could think of was to have a big number to use as the loop counter and decrement it in intervals. 102 is 40% of 255, or 2/5ths, so after incrementing twice for cells 1, 2, and 3 go back to cell 0 and decrement by 5. At the end of the loop we should have .
Some interesting bf-related links:
http://esolangs.org/wiki/Brainfuck_algorithms add, dup, swap, mul, if implemented in bf.