Tuesday, May 6, 2014

Given a number 123456789, two opearators + and *, value k , find all the such expressions that evaluates to the given value k

Problem

 Given a number 123456789 and two opearators + and *. You can use this two operators as many times u want. But you cant change the sequence of the number given there. The evaluated value is 2097.

e.g. 1+2+345*6+7+8+9=2097

You have to find all the such expressions that evaluates and value is equal to the given value. You can use concatenation of numbers like 345 is concatenated there.

Solution

 e.g. some more example
1+2+345*6+7+8+9 = 2097
12*3*45+6*78+9 = 2097
12*34+5*6*7*8+9 = 2097 



0 comments:

Post a Comment