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
0 <= n <= 255produces 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.
This is metagolf. Your score is the sum of the lengths of the scripts produced for
A poor solution to this challenge is:
I could do better than this if I only had a brain.
def bfconstant(n): return n*'+'
A better (though still poor) solution would be:
I'm much smarter than that other guy...
def golfbf(n): if n < 128: return '+'*n else: return '-'*(256-n)