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.
No comments:
Post a Comment