19
2
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.
1What operations are allowed? – anOKsquirrel – 2015-11-10T17:29:07.387
Related – FryAmTheEggman – 2015-11-10T17:30:10.547
1@FryAmTheEggman Is there enough similarity to call this a duplicate? I didn't think so because this challenge doesn't use exclusively one digit and does not have a specific RHS in mind (only equality). – Arcturus – 2015-11-10T17:38:40.377
I would have said duplicate and voted to close if I thought they were dupes :P Some of the approach can be quite similar, so I pointed people trying to answer the question well to another similar question, is all. – FryAmTheEggman – 2015-11-10T17:44:06.467
Ok, thanks. I'll keep the question up. – Arcturus – 2015-11-10T17:51:14.813
17DD/MM/YYYY > MM/DD/YYYY. – orlp – 2015-11-10T18:09:02.197
Is 05/01/2015 valid or do you want 5/1/2015? – Blue – 2015-11-10T18:24:36.467
@muddyfish MM/DD/YYYY would use 05/01/2015. – Arcturus – 2015-11-10T18:55:58.990
3I think you want to use equation in your question where you wrote expression (an expression is just one side of the equation, and then your question doesn't really make sense). – Paŭlo Ebermann – 2015-11-10T19:36:52.327
Similar? – MickyT – 2015-11-10T19:54:14.333
Can we use
==
in place of=
? – ETHproductions – 2015-11-10T21:03:44.220Also, can we use multiple equals signs (e.g.
110110 => 1-1=0^1=1*0
) – ETHproductions – 2015-11-10T22:35:47.730@ETHproductions Good idea, multiple equals signs in the expression seems like a good bonus. However,
==
isn't something that should occur. – Arcturus – 2015-11-11T03:09:18.8201Is this proven possible for any given date? – Zach Gates – 2016-04-04T05:08:52.873
Where is the input from? – Leaky Nun – 2016-04-23T10:23:07.753