Tag Info

Metagolf is golfing the output of a metaprogram. A metaprogram produces a program which solves a given task, and the length of that output determines the score of the original program.

Metagolf is golfing the output of a metaprogram. That is, you may be asked to write a program A, which given input I produces a short program A(I). The shorter A(I) is, the better.

For instance, consider the following challenge:

## Metagolf Brainfuck Constants

Write a program which, input an integer n with 0 <= n <= 255 produces a brainfuck script which creates that constant at the cursor. You can assume the tape is blank to the right (>) of the cursor, that -1 = 255, and the tape is unbounded. When your bf script ends, it must leave the tape past the cursor blank.

Scoring

This is metagolf. Your score is the sum of the lengths of the scripts produced for 0,1,2,...,255.

A poor solution to this challenge is:

## Python, 32640

I could do better than this if I only had a brain.

def bfconstant(n):
return n*'+'


Example Output

1 -> +

2 -> ++

255 -> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

A better (though still poor) solution would be:

## Python, 16384

I'm much smarter than that other guy...

def golfbf(n):
if n < 128:
return '+'*n
else:
return '-'*(256-n)


Example Output

1 -> +

2 -> ++

255 -> -