|
|
Up |
|
|
  |
Author: Albert van der HorstAlbert van der Horst Date: May 2, 2008 04:05
I have sorted the Euler problems from hardest to easiest,
and indeed the most interesting ones come up front.
This one gets me particularly stunned.
Find all quadrilaterals with angles (including those with diagonals).
that can be measured in whole degrees.
So a square fits the bill, because all those angles are 45 degrees.
They give an example of a non-trivial example with 20 and 50
degrees.
I cannot come up with something better than this
- guess all angles except one.
- calculate the last one using goniometric functions.
The problem states that if it is within 10-9 of a whole degree, it is
acceptable as a whole degree.
This is of course a nasty calculation.
Using fixed point calculations would even me more cumbersome.
I cannot find a way to do it exactly which would be more gratifying,
if only mathematically.
Takers anyone?
Groetjes Albert
|
| Show full article (1.06Kb) |
|
| | 22 Comments |
|
  |
Author: Marcel HendrixMarcel Hendrix Date: May 2, 2008 05:18
Albert van der Horst writes Re: The hardest Euler problem
> I have sorted the Euler problems from hardest to easiest,
> and indeed the most interesting ones come up front.
> This one gets me particularly stunned.
> Find all quadrilaterals with angles (including those with diagonals).
> that can be measured in whole degrees.
That's problem 177. Still some 137 to go for me :-)
I have found that some problems are interrelated. E.g. solving the first
prime problem makes the later prime problems a lot easier.
-marcel
|
| |
|
| | no comments |
|
  |
Author: caccac Date: May 2, 2008 07:40
Albert van der Horst wrote:
> I have sorted the Euler problems from hardest to easiest,
> and indeed the most interesting ones come up front.
As far as I can tell, the "difficulty" metric is the number of correct
solutions submitted with no factoring for the amount of time posted, and
as such, can be a bit misleading.
>
> This one gets me particularly stunned.
>
> Find all quadrilaterals with angles (including those with diagonals).
> that can be measured in whole degrees.
Slight restatement: find all convex quadrilaterals such that the angles
between the sides and the interior diagonals can be measured in whole
degrees.
> I cannot come up with something better than this
> - guess all angles except one.
> - calculate the last one using goniometric functions.
If the angles between two adjacent sides and the diagonal are both whole
number of degress, then the angle between the sides will be as well.
|
| Show full article (1.27Kb) |
| no comments |
|
  |
Author: Albert van der HorstAlbert van der Horst Date: May 2, 2008 09:09
>Albert van der Horst writes Re: The hardest Euler problem
>
>> I have sorted the Euler problems from hardest to easiest,
>> and indeed the most interesting ones come up front.
>
>> This one gets me particularly stunned.
>
>> Find all quadrilaterals with angles (including those with diagonals).
>> that can be measured in whole degrees.
>
>That's problem 177. Still some 137 to go for me :-)
>
>I have found that some problems are interrelated. E.g. solving the first
>prime problem makes the later prime problems a lot easier.
Couldn't find you in the scores yesterday. With 40 solved it is
easier : mhx.
I have solved three, my nickname is albert.
Factoring a >32 bit number is a breeze on a 64 bit Forth.
|
| Show full article (1.05Kb) |
| no comments |
|
  |
Author: William JamesWilliam James Date: May 3, 2008 17:06
Someone posted this PARI/GP solution to problem 12:
n=0; until(numdiv(n*(n+1)/2) > 500, n++); n*(n+1)/2
He said it took about 50ms on his Intel 2.52GHz.
A hint for problem 191: it's just a variaton of
problem 164.
|
| |
| no comments |
|
  |
Author: caccac Date: May 3, 2008 21:36
William James wrote:
> Someone posted this PARI/GP solution to problem 12:
>
> n=0; until(numdiv(n*(n+1)/2) > 500, n++); n*(n+1)/2
>
> He said it took about 50ms on his Intel 2.52GHz.
>
Sigh. My solution takes 1h45m. I think maybe PARI/GP knows things about
factoring that I don't.
> A hint for problem 191: it's just a variaton of
> problem 164.
I didn't have much problem with 191. 192 on the other hand... I whipped
out some code, looks good, runs quick, gets the wrong answer...
-- Charles
|
| |
| 14 Comments |
|
  |
Author: caccac Date: May 3, 2008 22:27
cac wrote:
> William James wrote:
>> Someone posted this PARI/GP solution to problem 12:
>>
>> n=0; until(numdiv(n*(n+1)/2) > 500, n++); n*(n+1)/2
>>
>> He said it took about 50ms on his Intel 2.52GHz.
>>
>
> Sigh. My solution takes 1h45m. I think maybe PARI/GP knows things about
> factoring that I don't.
>
Okay, all better now. A little Googling, and now I know how to count
factors. 0.7 seconds. The right algorithm makes all the difference.
-- Charles
|
| |
| no comments |
|
  |
Author: Marcel HendrixMarcel Hendrix Date: May 4, 2008 00:13
cac inbox.com> writes Re: The hardest Euler problem
[..]
>> Someone posted this PARI/GP solution to problem 12:
>> n=0; until(numdiv(n*(n+1)/2) > 500, n++); n*(n+1)/2
>> He said it took about 50ms on his Intel 2.52GHz.
What else to expect with a built-in number-of-divisors function?
> Sigh. My solution takes 1h45m. I think maybe PARI/GP knows things about
> factoring that I don't.
What you can easily see is that one only needs to count to below the
square root of u1, because each successful division delivers you two
valid divisors. If you take that into account, you solve the problem
in 800 ms (so short that I didn't think about making it faster).
The only (1-off ) complication is that u1 could be a perfect square
(however, it follows from the formula it can't).
Assuming you are doing this in Forth (why else mention it here):
: #divisors ( u1 -- u2 )
0 swap
dup s>f fsqrt fround f>s 1+ ( prefect square?)
1 ?do dup i mod 0= 2 and rot + swap loop drop ;
|
| Show full article (1.31Kb) |
| no comments |
|
  |
Author: caccac Date: May 4, 2008 01:31
Marcel Hendrix wrote:
> cac inbox.com> writes Re: The hardest Euler problem
> Assuming you are doing this in Forth (why else mention it here):
Actually, no. I was just responding to an ongoing discussion, and
going off-topic. My bad. My Forth is very rusty; I haven't written
anything significant in Forth since about '83. However, it is a
favorite of mine, and I have recently started to work with it again.
I have been trying some of the problem in Forth, but my brain is
old and rusty, and it will take time.
> I also find that some of the higher-numbered problems can be surprisingly
> simple. Unfortunately, some others can waste a day (44, 45 I can't solve
> by brute force).
I solved 44 quickly by computing lookup tables, and then searching them.
45 I solved by brute force.
-- Charles
|
| |
| 5 Comments |
|
  |
|
|
  |
Author: Marcel HendrixMarcel Hendrix Date: May 4, 2008 04:08
cac inbox.com> writes Re: The hardest Euler problem
> Marcel Hendrix wrote:
>> cac inbox.com> writes Re: The hardest Euler problem
>> Assuming you are doing this in Forth (why else mention it here):
> Actually, no. I was just responding to an ongoing discussion, and
> going off-topic. My bad. My Forth is very rusty; I haven't written
> anything significant in Forth since about '83. However, it is a
> favorite of mine, and I have recently started to work with it again.
> I have been trying some of the problem in Forth, but my brain is
> old and rusty, and it will take time.
If you are solving #191, there can't be much wrong with it.
>> I also find that some of the higher-numbered problems can be surprisingly
>> simple. Unfortunately, some others can waste a day (44, 45 I can't solve
>> by brute force).
> I solved 44 quickly by computing lookup tables, and then searching them.
> 45 I solved by brute force.
Anything over 6 seconds is "can't" for me :-) I finally let #44 run, and it
found the solution in about 4634 seconds. With the below optimization it
finds the solution in 9.6 seconds.
|
| Show full article (1.37Kb) |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|