Background
This puzzle is a variation on the four fours puzzle (itself the topic of a past question). Like that puzzle, the aim is to find mathematical expressions for different whole numbers, using only four digits and certain mathematical operators. In this case, however, the permitted digits are just 2, 0, 1 and 5. Each must appear precisely once in the solution and in the correct order. Surprisingly many whole numbers can be represented this way. Solvers are encouraged to try solving it by hand first, as it's strangely enjoyable.
Rules
Constants may be constructed from single or multiple digits:
- Integers: e.g. 2, 0, 15, etc.
- Decimals: e.g. .2, .01, 1.5, etc.
- Repeating decimals: e.g. .2~ (=0.222...), .15~ (=0.1555...), 20.15~~ (=20.1515...)
The following unary operations are permitted:
- Unary negation: -x
- Square root: sqrt(x)
- Integer factorial: x!
The following binary operations are permitted:
- Standard arithmetic operators: x+y, x-y, x*y and x/y
- Arbitrary exponentiation: x^y
- Arbitrary roots: rt[x](y) (= x'th root of y)
Task
Your program should print out expressions for as many of the integers between 0 and 100 as it can, and then output the number of expressions it has produced.
- The solutions must be printed in order in the format n=[expr].
- The expressions must use all the digits 2, 0, 1, 5, once each in that order.
- The expressions must be printed using the notation described above. Unnecessary parentheses are permitted but not required, as is whitespace. The order of operator precedence is unary negation, factorial, exponentiation, multiplication/division and addition/subtraction.
- The program need not return solutions for all the numbers. A program that simply outputs 0 is therefore valid; however, see the scoring section below.
- The program should run in under 15 minutes on a modern computer.
You may write a program or function. The expressions should be printed to STDOUT (or closest alternative). The number of expressions can be printed to STDOUT or returned as an integer. Standard code golf restrictions apply.
Example output
0=2*0*1*5
10=20*1*.5
42=((2+0!)!+1)!/5!
100=20*1*5
4
Scoring
Update: @orlp has noted a flaw in the scoring system. See http://meta.codegolf.stackexchange.com/questions/5106/way-of-salvaging-two-zero-one-five-puzzle-challenge for a discussion of how or whether this should be fixed.
Solutions are scored first by the number of expressions they produce and then by their code length in bytes. Hence, a 1000 byte program that produce 80 results will beat a 100 byte program that produces only 79 (though the latter could easily be extended to include the missing results).
For those who would like a motivating target, below is a lower bound on the number of expressions that can be represented. I don't plan to submit an entry, so it may well be possible to win with less!
At least 85 (out of 101), though it may well be higher.
Scoreboard
As an extra incentive, here is a summary of the score progression. Whenever you beat the highest score, feel free to add yourself to the top of the table (or ask someone else to).
- 0 expressions, 1 byte (Pyth): implementation that just outputs 0