I had this doubt some time ago: How can we find the Brainfuck program that outputs a certain sequence of characters/numbers in the shortest possible number of operations?For example, the quickest program to print value 100 is:

To recall, brainfuck has 8 operations:[] : loops>< : increase/decrease pointer+- : increase/decrease value,. : input/outputLoops count as two instructions and are not really necessary to print a string, so they can be left out. Input is also unnecessary here.

The fastest way to output value n is n times "+" followed by ".", but when printing multiple values it gets more difficult. The simplest way to do it is "print n1, next cell, print n2, next cell, print n3..." but this is obviously not the fastest way, for example, printing 4,5,6 would be:

My ideas were some sort of statistical analysis or an evolutive algorithm, but I wondered If there was a simple algorithm to find the quickest program other than brute-forcing. (I have the feeling it is NP-complete)

The problem is that the decision which cell to use depends on the following numbers (and, of course, on the previous numbers). I had some ideas but they all turned out to be flawed. Can't think of anything better than brute-forcing right now. But we can rule out loops as they always use more instructions than the unrolled version and no user interaction is need (= all loop conditions can be evaluated at "compile" time and can be eliminated)