Colored Configurations
This problem looks like quite difficult. Only 730 people solved it. But actually, it is quite simple, It is just a simple combination problem. Well, since the number is huge, we need a little bit help from computer to compute some parameters for our simple formula.
It runs under 1 ms.
Friday, May 31, 2013
project euler problem 194
project euler problem 192
Best Approximations
This problem is quite hard. My old code needs minutes to get the answer since I used my poor bigInteger class to find the best approximation. But if one asks google with appropriate key words, one can find some very useful web pages.
With the help of wikipedia, I find a better method. This method is quite fast, but for some situations, I still can not handle with only 64bit integers. I went back to my bigInteger class again to handle such situations and found the correct answer.
It takes 0.6 second.
This problem is quite hard. My old code needs minutes to get the answer since I used my poor bigInteger class to find the best approximation. But if one asks google with appropriate key words, one can find some very useful web pages.
With the help of wikipedia, I find a better method. This method is quite fast, but for some situations, I still can not handle with only 64bit integers. I went back to my bigInteger class again to handle such situations and found the correct answer.
It takes 0.6 second.
Thursday, May 30, 2013
project euler problem 193
Squarefree Numbers
This problem is not very difficult. There is a very famous principle to consider the double counting issue. I reviewed my old code and found it was not well written and takes 2.1 second to get the answer. This time I rewrote it with the same idea, it only takes 0.76 second.
I also tried to solve it with the idea I learned in problem 184. My code is not as efficient as Robert's code. I will reuse it when necessary. It is a great tool for more difficult problems.
This problem is not very difficult. There is a very famous principle to consider the double counting issue. I reviewed my old code and found it was not well written and takes 2.1 second to get the answer. This time I rewrote it with the same idea, it only takes 0.76 second.
I also tried to solve it with the idea I learned in problem 184. My code is not as efficient as Robert's code. I will reuse it when necessary. It is a great tool for more difficult problems.
Monday, May 27, 2013
project euler problem 191
Prize Strings
This is a simple dynamic programming problem. The time needed is less than 1 ms. I am surprised to find that I used a brute force style algorithm to get the answer in my old code.
This is a simple dynamic programming problem. The time needed is less than 1 ms. I am surprised to find that I used a brute force style algorithm to get the answer in my old code.
Sunday, May 26, 2013
project euler problem 189
Tri-colouring a triangular grid
I checked my old code. I could not fully understand it. I roughly understood that I was struggling with two different orientations of the triangles. But the run time is not too bad, 28ms.
I read the discussion today. I found that there was an easier way to solve the problem without considering too much about the orientations. The code is simple, easier to implement. But the only bad thing is that it took 0.6 second to get the answer.
But Robert_Gerbicz provided an ingenious way to solve the problem! (At least I found the algorithm in his post). It is much more efficient than his first approach. It is equivalent to use two different dynamic programmings in one problem.
I recommend everyone to read his post and figure out how his algorithm works. It is brilliant!
I checked my old code. I could not fully understand it. I roughly understood that I was struggling with two different orientations of the triangles. But the run time is not too bad, 28ms.
I read the discussion today. I found that there was an easier way to solve the problem without considering too much about the orientations. The code is simple, easier to implement. But the only bad thing is that it took 0.6 second to get the answer.
But Robert_Gerbicz provided an ingenious way to solve the problem! (At least I found the algorithm in his post). It is much more efficient than his first approach. It is equivalent to use two different dynamic programmings in one problem.
I recommend everyone to read his post and figure out how his algorithm works. It is brilliant!
Thursday, May 23, 2013
project euler problem 190
Maximising a weighted product
This is a simple problem. I solved it two minutes. A little bit calculus knowledge might be of help. If one has some knowledge about inequality, it can be easily solved.
This is a simple problem. I solved it two minutes. A little bit calculus knowledge might be of help. If one has some knowledge about inequality, it can be easily solved.
Wednesday, May 22, 2013
project euler problem 188
The hyperexponentiation of a number
Sigh! Another lesson of not learning from the discussion thread.
This problem needs a little bit background knowledge. It is called Euler's theorem. I think it is fair to reveal such kind of information. Otherwise, how can one solve this problem?
I do not even know there is a problem like this. After I solved this problem, I totally forgot it. I lost my old code. I do not even know how I solved it. Now I am trying to solve it again. I immediately realized how to solve it since I had experienced a hard time to solve problem 282: the Ackermann function. If I learned from problem 188, 282 is trivial.
Why 3390 people solved this problem but only 560 people solved problem 282? So many people left from project euler?
Sigh! Another lesson of not learning from the discussion thread.
This problem needs a little bit background knowledge. It is called Euler's theorem. I think it is fair to reveal such kind of information. Otherwise, how can one solve this problem?
I do not even know there is a problem like this. After I solved this problem, I totally forgot it. I lost my old code. I do not even know how I solved it. Now I am trying to solve it again. I immediately realized how to solve it since I had experienced a hard time to solve problem 282: the Ackermann function. If I learned from problem 188, 282 is trivial.
Why 3390 people solved this problem but only 560 people solved problem 282? So many people left from project euler?
Subscribe to:
Posts (Atom)