Skip to main content
1 of 6
randomra
  • 20.9k
  • 4
  • 48
  • 113

Brainfuck subprograms with unique outputs

You should write a 100-byte long brainfuck (BF) program.

One character will removed from it in every possible way the resulting 100 new (99-byte long) programs. E.g. for the program ++.>. the 5 programs are +.>., +.>., ++>., ++.. and ++.> .

Your score will be the number of unique outputs the 100 programs generate. Higher score is better.

Details

  • Your program will be terminated after outputting the first character.
  • Invalid or non-terminating programs and are not counted towards the score.
  • The BF cells are 8 bit wrapping ones. (255+1=0, 0-1=255)
  • Your program is given no input. If you use , in the code it set's the current cell to 0.
  • There are no cells on the left side of the starting position. E.g. <. is invalid but .< is valid as the execution is terminated at .. The tape is unbounded in the other direction.
  • Programs with unbalanced brackets ([ and ]) are invalid.
  • Your original program can be shorter than 100 bytes as it's easy to extend it to 100 bytes without changing the score.
  • Your original program doesn't have to be valid BF code.

You can use this python3 program (ideone link) to determine the score of your answer.

Example

(For simplicity this program is shorter than 100 bytes.)

Solution: ++,+[-]+><.-,-. Score: 3 Explanation: Subprogram => Output +,+[-]+><.-,-. => 1 +,+[-]+><.-,-. => 1 +++[-]+><.-,-. => 1 ++,[-]+><.-,-. => 1 ++,+-]+><.-,-. => None ++,+[]+><.-,-. => None ++,+[-+><.-,-. => None ++,+[-]><.-,-. => 0 ++,+[-]+<.-,-. => None ++,+[-]+>.-,-. => 0 ++,+[-]+><-,-. => 255 ++,+[-]+><.,-. => 1 ++,+[-]+><.--. => 1 ++,+[-]+><.-,. => 1 ++,+[-]+><.-,- => 1 Unique outputs are [0, 1, 255] Score is 3 for ++,+[-]+><.-,-. (length = 15) 

In case of a tie the winner is the earlier poster.

Bonus puzzle: without the bolded restriction can you find a program with score 100?

randomra
  • 20.9k
  • 4
  • 48
  • 113