# Large Numbers in BF

## Background

The language BrainF*** (or simply BF), is an extremely minimal programming language. We're going to strip it back even further by eliminating IO operations; only the sub-langage defined by the operations +-<>[], henceforth referred to as BF-subset, shall be used. The BF variant considered has a tape extending infinitely to the left and right, and cells which can take on any integer value without overflowing, and which are initialized to 0.

For those unfamiliar with BF, this explanation is adapted from the esolangs BF page.

A BF-subset program is a sequence of commands. The commands are executed sequentially, with some exceptions: an instruction pointer begins at the first command, and each command it points to is executed, after which it normally moves forward to the next command. The program terminates when the instruction pointer moves past the last command.

>   increment the data pointer (to point to the next cell to the right).
<   decrement the data pointer (to point to the next cell to the left).
+   increment (increase by one) the byte at the data pointer.
-   decrement (decrease by one) the byte at the data pointer.
[   if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
]   if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.


If a BF-subset program terminates, its score is defined as the final value of the cell which the program halts at, otherwise 0. Your challenge is to write a program to generate BF-subset programs of each length between 1 and 20 inclusive, such that the total score is maximized.

The winner of the contest will be the entrant with the highest total score; in case of a tie, the shortest program takes the title. Your program must be fast enough for you to run it to completion.

## Example Output and Scores

+                   01
++                  02
+++                 03
++++                04
+++++               05
++++++              06
+++++++             07
++++++++            08
+++++++++           09
++++++++++          10
+++++++++++         11
++++++++++++        12
+++++++++++++       13
++++++++++++++      14
+++++++++++++++     15
++++++++++++++++    16
+++++++++++++++++   17
++++++++++++++++++  18
+++++++++++++++++++ 19
+++++++++++++++++++ 20


Here, the total score is 210.

Edit: Changed the maximum length from 17 to 20.

• How can we test our submissions? Also, given that I expect these values to grow astronomically, I suspect that only the length-17 entry to matter in principle. – xnor Apr 4 '17 at 21:21
• Isn't this basically meta-golf of something like output Graham's number? – mbomb007 Apr 4 '17 at 21:24
• @xnor For short lengths, the values actually stay quite small. – user1502040 Apr 4 '17 at 21:44
• @user1502040 That's fair, I see the really astronomical programs seem to take about twice that many characters. I do have a concern that if someone finds an exceptionally good solution, the only limit will be running it to completion even when the result is mathematically known. So I'd suggest ditching that rule. – xnor Apr 4 '17 at 21:48
• Also your program for 20 is too short. – ASCII-only Apr 4 '17 at 21:59

# 309

+                    01
++                   02
+++                  03
++++                 04
+++++                05
++++++               06
+++++++              07
++++++++             08
+++++++++            09
++++++++++           10
+++++++++++          11
++++++++++++         12
+++++++++++++        13
++++[->++++<]>       16
+++++[->++++<]>      20
+++++[->+++++<]>     25
++++++[->+++++<]>    30
++++++[->++++++<]>   36
+++++++[->++++++<]>  42
+++++++[->+++++++<]> 49

• Do these all match the best-known values from the constants page? – xnor Apr 4 '17 at 21:54
• @xnor Not sure, right now I'm checking through it. EDIT: Yeah, looks like they do, but I might have made a mistake. – ASCII-only Apr 4 '17 at 21:54
• @orlp But loops only run while the cell has a nonzero value – ASCII-only Apr 4 '17 at 22:26
• @ASCII-only I misread the answer, I removed my downvote. – orlp Apr 4 '17 at 22:28