Showing posts with label arithmetic progression. Show all posts
Showing posts with label arithmetic progression. Show all posts

Sunday, April 7, 2013

project euler problem 093

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.

Monday, April 1, 2013

project euler problem 086

Cuboid route

Among the first 100 problems, this one is not easy.

Since my old code was lost, I rewrote it. It still took me three  hours to get it work in a relatively efficient way. It takes less than 1ms for my optimized version to get the correct answer. 

Update 10/05/2017,  I found my previous code for this problem is not efficient because I did not choose the number range carefully and I need to set the maximum to be large enough to get a correct answer for n=1e11.  It is a little bit tricky to find an appropriate limit for the pythagorean triangle numbers. There is still room to make improvement, but I will live with it since I have already passed the projecteuler+ tests for this problem. 


Saturday, February 16, 2013

project euler problem 001

Multiples of 3 and 5

I first started working on project euler in Aug 2011, I really enjoyed solving most of the problems. 

 This is an extremely easy problem, everyone can solve it. No comments needed.