![]() |
|
|
#1 |
|
Oct 2007
Manchester, UK
5·271 Posts |
I'm sure a lot people here are already familiar with Project Euler, but nevertheless, I found the latest puzzle to be quite interesting and thought I'd share it here.
It's a fairly easy one to understand, but coming up with an elegant solution was extremely hard. So hard that I in fact did not manage it, and instead took a brute force approach, albeit a very well optimised one. For anyone that wants to have at it, here's the link: http://projecteuler.net/problem=372 Of course, there are many more problems on there that are fun too. |
|
|
|
|
|
#2 |
|
Dec 2010
Monticello
179510 Posts |
Project Euler is what lead me here!!!
Did you notice that you can immediately halve the size of the search space by noting that on one side of x=y, the answer is always even? |
|
|
|
|
|
#3 |
|
Oct 2007
Manchester, UK
5·271 Posts |
Indeedily, I made many optimisations, but when all was said and done it was still a fairly long run time. Many people in the forum for that problem (which you can only see when you have completed the problem) had code that ran much much faster because they used far cleverer methods.
|
|
|
|
|
|
#4 |
|
Dec 2011
1810 Posts |
Very interesting. I drew a quick graph of the solution set for R(0,500), and it's definitely a very pretty pattern.
|
|
|
|
|
|
#5 | |
|
Feb 2012
11 Posts |
Quote:
sqrt(2)-sqrt(1) + sqrt(4)-sqrt(3) + .... + sqrt(n+1)-sqrt(n) ? And if so, do you know the name os such a serie ? Many thanks |
|
|
|
|
|
|
#6 | |
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17·251 Posts |
Quote:
The sum from n=1 to m is equal to |
|
|
|
|
|
|
#7 | |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
Quote:
Code:
sum(X=2,8,sqrt(X)-sqrt(X-1);X=X+2) Code:
(16:21)>sum(X=1,6,sqrt(X)-sqrt(X-1)) |
|
|
|
|
|
|
#8 | |
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17×251 Posts |
Quote:
|
|
|
|
|
|
|
#9 | |
|
"Forget I exist"
Jul 2009
Dumbassville
838410 Posts |
Quote:
Code:
(16:15)>sum(X=2,2,sqrt(X)-sqrt(X-1);X=X+2) %112 = 4 (16:15)>sum(X=2,4,sqrt(X)-sqrt(X-1);X=X+2) %113 = 15 (16:15)>sum(X=2,6,sqrt(X)-sqrt(X-1);X=X+2) %114 = 30 (16:15)>sum(X=2,8,sqrt(X)-sqrt(X-1);X=X+2) %115 = 49 30-15=15 15-4=11 second order differences: 19-15=4 15-11 = 4 second order differences are the same ( and yes I tested at least one more of these now) so it starts for x steps in 4*x^2 ... : the second order differences of the result of subtracting 4*x^2 from each appears to be constant at -4. |
|
|
|
|
|
|
#10 |
|
Feb 2012
67 Posts |
There's a pastebin for this problem http://pastebin.com/ZMk5jK1b
But it seems to be a very unoptimized algorithm |
|
|
|
|
|
#11 | |
|
Oct 2007
Manchester, UK
5×271 Posts |
Quote:
|
|
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Project Euler | jhs | Puzzles | 32 | 2021-01-19 04:05 |
| Project Euler 486 | lavalamp | Puzzles | 8 | 2015-02-04 14:28 |
| Euler (6,2,5) details. | Death | Math | 10 | 2011-08-03 13:49 |
| Project Euler | Mini-Geek | Lounge | 2 | 2009-10-23 17:19 |
| Bernoulli and Euler numbers (Sam Wagstaff project) | fivemack | Factoring | 4 | 2008-02-24 00:39 |