19
1
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 subprograms are +.>.
, +.>.
, ++>.
, ++..
and ++.>
.
Your score will be the number of unique outputs the 100 programs generate. Higher score is better.
Details
- Your programs will be terminated after outputting the first character.
- Invalid or non-terminating programs and programs generating empty outputs 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 to0
. - 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. (For long-running programs you may need to modify the maxstep
variable.)
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 one with the shorter code. (Your program can be shorter than 100 bytes as stated in the Details section.) If the codes are equal length the winner is the earlier poster.
Bonus puzzle: without the bolded restriction can you find a program with score 100?
I solved the bonus puzzle; the answer is (censored). – AJMansfield – 2015-03-30T16:05:30.447
@AJMansfield Could you edit your comment so others could think about the puzzle too? E.g change your solution to a http://pastebin.com/ link which contains the answer.
– randomra – 2015-03-30T16:08:52.8073
Hmm. I wrote a genetic optimizer for this question to try to find micro-improvements to existing answers, but it's not too successful so far. They're getting stuck at 79 and 43 respectively. Ah well—it was worth a shot!
– wchargin – 2015-03-31T03:58:34.410