The Four fours puzzle is a popular recreational mathematical puzzle that involves using exactly four 4s (and no other number) and a defined set of operations to reach every number from 0 to a given maximum.
In this version, the only following operators are allowed:
- Any grouping symbols may be used
- Addition (
+), Subtraction (
-), Multiplication (
*), Division (
- Factorial (
!), Gamma function (
- Exponentiation (
^), Square root (
- Concatenation (eg.
- Decimal point (eg.
4s), Overbar (eg.
.4~ = 4/9)
Standard order of operations applies.
Your program should generate, given an input between 0 and 100 inclusive, a correct solution for that input. If the program outputs an invalid solution to any input, that program is invalid.
For example, with an input of
0, your program might generate
The use of external modules is not allowed. Only
_.4~ is allowed for the overbar operator - that is, only one
4 can be behind the decimal point.
This is code golf, so shortest solution wins.
Edit: To be extra clear, the program must output a set of the above operations applied to exactly four
4s - no more, no less. Also,
.4 = 4/10 is a valid term, and counts as using only one