Arithmetic expressions
My old code is too complicated, so I rewrote the code. The new code is much simpler and easier to read. It took 1.7 second for my old code to finish while the new one only needs 0.048 second.
But I do not have a good solution if we change the number of distinct numbers to 10 or even larger number. There is another similar problem in project Euler which is more difficult. Problem 259. Some of the strategy used in this problem may also apply to that problem.
Update 10/13/2017
One
version of my code missed the role of parenthesis but the result of the
original ProjectEuler problem is still correct. Thanks for projectEuler+ to help me fix the bug.
No comments:
Post a Comment