mersenneforum.org  

Go Back   mersenneforum.org > Fun Stuff > Puzzles

Reply
 
Thread Tools
Old 2012-03-02, 18:39   #45
voidme
 
Feb 2012

67 Posts
Default

That still won't guarantee integer coordinates because the y=N line means we cut off x at any moment. integer^2/decimal^2 does not guarantee an integer, nor does decimal^2 for that matter

the idea is looking at the straight x vs y lattice plane and determining which areas are valid vs invalid based on y^2/x^2, but the arbitrary cutoff at the top kills pick's theorem i'm sure. unless you can round it off and just-so-happen to not lose any/gain any lattice points?

seems possible but you never know with large scale numbers, especially since i'm sure the x-cutoff will be all over the place with respect to one whole x value to the next, and I don't think changing that is a trivial matter

Last fiddled with by voidme on 2012-03-02 at 18:54
voidme is offline   Reply With Quote
Old 2012-03-02, 20:43   #46
PdB
 
Feb 2012

1110 Posts
Default

@lavalamp I investigated the triangles approach after you mentioned in a previous post that someone on the Euler forum posted a code that executes in 1 sec or so. Although you added that you didn't understand the algo, can you confirm that it is not dealing with triangles areas ? This would help !

Last fiddled with by PdB on 2012-03-02 at 20:44
PdB is offline   Reply With Quote
Old 2012-03-02, 22:36   #47
lavalamp
 
lavalamp's Avatar
 
Oct 2007
Manchester, UK

5×271 Posts
Default

Quote:
Originally Posted by voidme View Post
That still won't guarantee integer coordinates because the y=N line means we cut off x at any moment. integer^2/decimal^2 does not guarantee an integer, nor does decimal^2 for that matter

the idea is looking at the straight x vs y lattice plane and determining which areas are valid vs invalid based on y^2/x^2, but the arbitrary cutoff at the top kills pick's theorem i'm sure. unless you can round it off and just-so-happen to not lose any/gain any lattice points?

seems possible but you never know with large scale numbers, especially since i'm sure the x-cutoff will be all over the place with respect to one whole x value to the next, and I don't think changing that is a trivial matter
Perhaps we're thinking of different approaches, but in my head, only integer coordinates would be used.

Quote:
Originally Posted by PdB View Post
@lavalamp I investigated the triangles approach after you mentioned in a previous post that someone on the Euler forum posted a code that executes in 1 sec or so. Although you added that you didn't understand the algo, can you confirm that it is not dealing with triangles areas ? This would help !
At least one person did use Pick's theorem as PART of their solution, yes. It seems that many more did not.
lavalamp is offline   Reply With Quote
Old 2012-03-02, 22:54   #48
voidme
 
Feb 2012

67 Posts
Default

Quote:
Originally Posted by lavalamp View Post
Perhaps we're thinking of different approaches, but in my head, only integer coordinates would be used.

At least one person did use Pick's theorem as PART of their solution, yes. It seems that many more did not.
I refer to the sort of picture on the front page. straight x-y plane lattice ranging from (M,M) to (N,N) with bands representing valid areas where floor(y^2/x^2) is odd
voidme is offline   Reply With Quote
Old 2012-03-03, 01:33   #49
lavalamp
 
lavalamp's Avatar
 
Oct 2007
Manchester, UK

5·271 Posts
Default

I understand that, and I saw Jaxon's plot. But rather than fitting triangles (trapeziums) on that plot (on shapes that aren't actually triangular (trapeziar?)), do it for y^2 against x^2.

For example, for R(100,10000), instead of marking curves for the range 101 to 10000 on both axes, mark trapeziums between the range 10201 and 100000000 on both axes and count the lattice points enclosed (and on the lower boundry).

This may or may not help, since now the problem is subtracting all pairs where either x or y or both are not perfect squares. It may turn out to be equally as hard.

Last fiddled with by lavalamp on 2012-03-03 at 01:33
lavalamp is offline   Reply With Quote
Old 2012-03-03, 02:58   #50
TimeWizid
 
Mar 2012
United States

316 Posts
Default

I am so close but am getting bogged down by corner cases and possibly precision errors. My algorithm correctly calculates the first two examples, and incorrectly calculates the actual problem within a second. I use the strategy of calculating the triangle area, like others have mentioned. The tricky part is calculating the area efficiently. Here is a visualization that gives a general idea of how to do so. I hope this helps!
TimeWizid is offline   Reply With Quote
Old 2012-03-05, 21:19   #51
voidme
 
Feb 2012

67 Posts
Default

I am close myself but precision errors are owning me. This program takes so damn long to run. debug hell
voidme is offline   Reply With Quote
Old 2012-03-06, 20:01   #52
PdB
 
Feb 2012

11 Posts
Default Got it !

At last, after switching from Ruby to C++ and increasing the computational precision, I got the right answer...
PdB is offline   Reply With Quote
Old 2012-03-06, 21:49   #53
lavalamp
 
lavalamp's Avatar
 
Oct 2007
Manchester, UK

5×271 Posts
Default

I bet it ran faster too!
lavalamp is offline   Reply With Quote
Old 2012-03-06, 23:44   #54
voidme
 
Feb 2012

67 Posts
Default

you all make me weep :( So close yet so far
voidme is offline   Reply With Quote
Old 2012-03-07, 14:28   #55
voidme
 
Feb 2012

67 Posts
Default

yeah this is absurd, tired of running this thing to find that it's wrong because of lame precision issues
voidme is offline   Reply With Quote
Reply



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

All times are UTC. The time now is 03:07.


Sat Jul 17 03:07:02 UTC 2021 up 50 days, 54 mins, 1 user, load averages: 1.34, 1.29, 1.30

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.