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.
44
is two4
s) - Decimal point (eg.
4.4
is two4
s), 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 44-44
.
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 4
s - no more, no less. Also, .4 = 4/10
is a valid term, and counts as using only one 4
.
!(4)
rather than(4)!
)? \$\endgroup\$