This is sort of what I expected, but thought I should get as much input as possible before spending a lot of time running up some blind alley.

[quote=282324:@Dave S]40 million different expressions?

or a handful of equations with 40 million possible sets of datum?

[/quote]

Yes, 40 million unique expressions, not just different data. Actually, in many cases it will be 80 million. However, I was in error when I said that is what the current application is solving. In fact, it’s only about 4 million expressions per run currently. But the updated one will be either 40 million or 80 million, depending on certain criteria.

To elaborate, this is all about solving an arithmetic puzzle. As we input more years into Moore’s law, we receive in return the ability to crunch ridiculously more numbers, and things that we wouldn’t have dreamed of trying a few years ago, are completely practical now. This particular one is a puzzle proposed some time ago:

Given the string of digits: 0123456789, the problem is to insert the arithmetic operators + - * / wherever and as often as necessary to create an expression that evaluates to a certain given value. For example let’s say the given value is the current year 2016. Then the possible solutions are:

0-1-2+3/4*5*67*8+9*

01+2*34*5*6-7-8-9*

0/1+234*5*6-7-8-9

0+1*2*34*5*6-7-8-9

0-1-2+3+4*567*8/9

0+1+2-3+4*567*8/9

0*1*2*3+4*567*8/9*

0/12*3+4*567*8/9*

01/2*3+4*567*8/9*

0/1/23+4*567*8/9

0*12*3+4*567*8/9

0/12*3+4*567*8/9*

01*2/3+4*567*8/9*

0/12/3+4*567*8/9

0*1/2/3+4*567*8/9*

0/1/2/3+4567*8/9*

012/3+4*567*8/9

0/12/3+4*567*8/9

0*1*23+4*567*8/9

0/1*23+4*567*8/9*

01/23+4*567*8/9

0/1/23+4*567*8/9

0*123+4*567*8/9*

0/123+4567*8/9

And for the digit string: 9876543210, the possible solutions are:

9-8+7/6*54*32-1+0

98*76-5432*1+0

98*76-5432/1+0*

9-8+7/654*32-1-0*

9876-5432*1-0*

9876-5432/1-0

98*76-5432+1*0

98*76-5432-1*0

98/7/6/5*432*10

9+8+7/6*54*32+1+0

9+8+7/6*54*32+1-0

9-8+7*65*4+3+210

In my current version of the program, it takes about 80 seconds to generate all of the possible solutions for a given digit string and target value. It does this by the inelegant method of generating every possible permutation of syntactically correct expressions, and then evaluating them to see if they are equal to the target value. However, there are certain target values for which there are no solutions (for example there is no solution for the digit sequence 0123456789 and the target value 3897). So, I’ve been contemplating the possibility of allowing for slightly more complicated expressions which would include parentheses, and other operators such as exponentiation, and factorial. In order to do this I would need to rework the current expression evaluator.

One of the advantages of having the program generate all of the expressions is that I can invent my own syntax where it would be more efficient, as long as it can be easily translated back into infix for final display.

This is the sort of thing that I think about when I’m supposed to be working. But I rationalize it by recognizing that whatever I learn from this exercise, it may come in handy for some serious work later on.