ZeroBF

ZeroBF is a compression scheme for Brainfuck invented by User:Zzo38, the program is encoded as a single number. Assume the tape is unbounded in both directions and all cells start at zero.

At each step, you do: Divide the number by the number of possible commands, write the command according to the remainder, and then set the number to quotient. Repeat until number is zero.

At beginning of program: 0=, 1=+ 2=- 3=. After a + not in a loop if a > hasn't appeared yet: 0=+ 1=> 2=[ 3=. After a + in a loop if a > hasn't appeared yet: 0=+ 1=> 2=[ 3=. 4=] After a - not in a loop if a > hasn't appeared yet: 0=- 1=> 2=[ 3=. After a - in a loop if a > hasn't appeared yet: 0=- 1=> 2=[ 3=. 4=] After a + not in a loop: 0=+ 1=< 2=> 3=[ 4=. After a + in a loop: 0=+ 1=< 2=> 3=[ 4=. 5=] After a - not in a loop: 0=- 1=< 2=> 3=[ 4=. After a - in a loop: 0=- 1=< 2=> 3=[ 4=. 5=] After a < not in a loop: 0=< 1=- 2=+ 3=[ 4=. 5=, After a < in a loop: 0=< 1=- 2=+ 3=[ 4=. 5=, 6=] After a > not in a loop: 0=> 1=- 2=+ 3=[ 4=. 5=, After a > in a loop: 0=> 1=- 2=+ 3=[ 4=. 5=, 6=] After a [ if a > hasn't appeared yet: 0=, 1=+ 2=- 3=. 4=> 5=[ After a [: 0=, 1=+ 2=- 3=. 4=< 5=> 6=[ After a ] not in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> After a ] in a loop with nothing before the loop that just ended: 0=, 1=+ 2=- 3=. 4=< 5=> After a ] in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> 6=] After a, not in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> 6=[ After a, in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> 6=[ 7=] After a. not in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> 6=[ After a. in a loop: 0=, 1=+ 2=- 3=. 4=< 5=> 6=[ 7=] Note: This list assumes that the program might use binary I/O. For a program that does not use binary I/O, a. cannot appear directly after a ]

If each cell stores 1 bit, it can be simplified to (* toggles the bit): At beginning of program: 0=, 1=* 2=. After a * not in a loop if > hasn't appeared yet: 0=. 1=[ 2=> After a * in a loop if > hasn't appeared yet: 0=. 1=[ 2=> 3=] After a * not in a loop: 0=. 1=[ 2=> 3=< After a * in a loop: 0=. 1=[ 2=> 3=] 4=< After a < not in a loop: 0=. 1=, 2=* 3=[ 4=< After a < in a loop: 0=. 1=, 2=* 3=[ 4=< 5=] After a > not in a loop: 0=. 1=, 2=* 3=[ 4=> After a > in a loop: 0=. 1=, 2=* 3=[ 4=> 5=] After a [ if a > hasn't appeared yet: 0=, 1=* 2=. 3=> 4=[ After a [: 0=, 1=* 2=. 3=< 4=> 5=[ After a ] not in a loop: 0=, 1=* 2=. 3=< 4=> After a ] in a loop with nothing before the loop that just ended: 0=, 1=* 2=. 3=< 4=> After a ] in a loop: 0=, 1=* 2=. 3=< 4=> 5=] After a, not in a loop: 0=, 1=* 2=. 3=< 4=> 5=[ After a, in a loop: 0=, 1=* 2=. 3=< 4=> 5=[ 6=] After a. not in a loop: 0=, 1=* 2=. 3=< 4=> 5=[ After a. in a loop: 0=, 1=* 2=. 3=< 6=> 5=[ 6=]