The program tries to equations using "nNumber" "nDigit's" to obtain answers 1 to "MaxN" with specified operation
four4 [nDigit nNumber MaxN [+] [-] [*] [/] [^] [sqrt] [percent] [fact] [neg] [repeat]]
sqrt: sqaure root
percent: %, i.e. divide by 100
fact: factorial
neg: negation, allow -4
^: exponentiation
repeat: allow repeating fraction, i.e. .(4)' = 0.44444 = 4/9
0 <= nDigit <= 9
Example:
PUZZLE
PUZZLE 4 4 100 (using four 4's to make 1 to 100)
PUZZLE 2 2 10 (using two 2's to make 1 to 10)
PUZZLE 3 4 100 (using four 3's to make 1 to 100)
PUZZLE 4 4 100 + - * / (using four 4's to make 1 to 100, allow only + - * / as operation)
v0.40
Compute four 4's, 1 to 100, with only + - * /, only output if a number can be formed
v0.65
Add check to prevent overflow error
Add unary operation, sqrt, factorial, percent, negation
Add binary operation, power
Add the option to adjust to any digit, any number, and any binary/unary operation
v0.67
Add checks to avoid overflow
Add some optimizations so the code runs slightly fasters
v0.80
Add expression tree to record expression, output result in pre-order
v0.90
Change the expression tree to an acylic graph with hash table on every node.
v0.92
Add priority to every node, also add output in infix notation
Change it so that repeating fraction of 0.4 is displayed as 0.(4)' not 0.444444
v0.94
Add codes to fix round-off error. I.e. 28.4/0.4 != 71 in double, thus, I add some check against this situation
v0.96
Add codes to guard against 0.4 ^ (4 ^ 44) != 0
v1.00
Add the command-line input
Remove output in pre-order notation