In my Economics class, my friends and I like to come up with ways to rearrange the digits in the date (in MM/DD/YY) format to create a valid mathematical equation. For the most part, we are allowed to use addition, subtraction, multiplication, division, parentheses, and exponentiation in addition to concatenation.
Your program should do something similar. The program should import the current date and insert operators to print an expression according to the following rules.
- The digits MUST be used in order. Rearrangement of digits is not allowed.
- The resulting expression must be mathematically accurate.
- Addition, subtraction, multiplication, division, exponentiation, and use of parentheses is allowed. So is concatenation of digits. However, not all operations are necessary. You cannot use a subtraction sign to make a digit negative (like
-1+1+11=10
on November 11, 2010). - The program must run in 60 seconds on a standard machine.
For example, this challenge was written on November 10, 2015. The program would interpret this as 11/10/15. A sample output would be (1+1)/10=1/5
.
Bonuses
You may multiply the number of bytes in your code by 0.9 for each one of the following your program supports.
- The program prints all possible expressions that can be formed, separated by newlines. Multiply by an additional 0.95 if the expressions are listed in increasing order of additional symbols.
- The program also works for MM/DD/YYYY dates, printing a possibility with the first two digits of the year in addition to the possibility without. If this bonus is combined with the first bonus, all possibilities with the first two digits of the year must be printed.
- The program also prints an equation for when there are multiple equalities (for example, on November 11, 2011,
1=1=1=1=1=1
would be printed, in addition to possibilities such as1*1=1=1=1=1
,1*1*1=1=1=1
, and1*1*1*1=1=1
. All such cases must be printed for the first bonus to be achieved. - The program supports conversion to bases between 2 and 16. Note that if the base is not 10, all numbers in the expression must be written in the same base, and
(Base b)
must be written after the expression (withb
replaced accordingly).
This is code golf, so standard rules apply. Shortest code in bytes wins.