Brainfuck :brain::middle_finger: === ```brainfuck= +-,.[] ``` > variable name `x, y, temp0, temp1,...` should be replaced by`<` or `>` to move to its position in real code > `temp` prefix: temporary cell initialize to 0 > `Code` prefix: code block :::danger most code might consume the input. use [copy value](https://hackmd.io/@NDR/Brainfuck#copy-value) to copy the input if necessary ::: --- [TOC] ## copy value * set `y` as a copy of `x` ```brainfuck= x[y+temp0+x-] temp0[x+temp0-] // x = temp0 ``` ## arithmetic * x = 0 ```brainfuck= x[-] ``` * y = x ```brainfuck= x[y+x-] ``` * z = x+y ```brainfuck= x[z+x-] y[z+y-] ``` * z = x-y ```brainfuck= x[z+x-] y[z-y-] ``` * z = x*y ```brainfuck= x[ y[ z+temp0+ y-] temp0[y+temp0-] // y = temp0 x-] ``` * z = x/y ## logic gate * y = NOT x ```brainfuck= x[y-x-]y+ ``` ## compare * z = (x > y) ## condition ## reference * https://esolangs.org/wiki/Brainfuck_constants * https://esolangs.org/wiki/Brainfuck_algorithms