Problem 351
Forum rules
As your posts will be visible to the general public you
are requested to be thoughtful in not posting anything
that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you
are requested to be thoughtful in not posting anything
that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Problem 351
how exactly "hidden from the center" is defined ?
why the points that are circled in red in this picture:
are not hidden from the center ?
why the points that are circled in red in this picture:
are not hidden from the center ?
Re: Problem 351
Because there is a straight line from the centre to any of those points which does not hit any of the other points of the grid.elr wrote:how exactly "hidden from the center" is defined ?
why the points that are circled in red in this picture:
are not hidden from the center ?
 Attachments

 p351hexorchard.png (6.54 KiB) Viewed 7335 times
_{Jaap's Puzzle Page}
 Marcus_Andrews
 Administrator
 Posts: 1452
 Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 351
There is a new PDF for this problem, which should come in handy for certain types of problems that solvers may be having difficulty with lately.

 Posts: 41
 Joined: Tue Jan 21, 2014 2:06 pm
 Location: The Netherlands
Re: Problem 351
Argh... I've spent hours working on this problem, and finally I've got a good, fast algorithm: it gives the answer for 100000 in 0.13 seconds (while doing nothing takes 0.08 seconds).
But when I try 1000000, the program completely stops working and it gives an error: ProjectEuler.exe (the name) has stopped working. It returns 1073741571 (0xC00000FD). I've tried using unsigned long long ints instead of long long ints, but to no prevail. Does anyone know what the problem might be?
EDIT: Thanks mdean and Marcus, solved .
But when I try 1000000, the program completely stops working and it gives an error: ProjectEuler.exe (the name) has stopped working. It returns 1073741571 (0xC00000FD). I've tried using unsigned long long ints instead of long long ints, but to no prevail. Does anyone know what the problem might be?
EDIT: Thanks mdean and Marcus, solved .
Last edited by pimspelier on Sun Mar 02, 2014 11:26 am, edited 1 time in total.
Re: Problem 351
Impossible to guess without seeing the code (don't post that here, I have solved the problem so you can pm me if it's C/C++ and you want me to take a peek) . First figure out where the program is crashing, then figure out why the program is crashing.pimspelier wrote:Argh... I've spent hours working on this problem, and finally I've got a good, fast algorithm: it gives the answer for 100000 in 0.13 seconds (while doing nothing takes 0.08 seconds).
But when I try 1000000, the program completely stops working and it gives an error: ProjectEuler.exe (the name) has stopped working. It returns 1073741571 (0xC00000FD). I've tried using unsigned long long ints instead of long long ints, but to no prevail. Does anyone know what the problem might be?
 Marcus_Andrews
 Administrator
 Posts: 1452
 Joined: Wed Nov 09, 2011 5:23 pm
Re: Problem 351
Sounds like it may be a stack overflow, based on the error code (in this case, possibly a recursive algorithm that is trying to nest too deeply).
Re: Problem 351
Hmm, I was confident I had the right answer, based on (i) a proof and (ii) the fact that my answers for small values of n matched those in the problem text...but the little man gave me a red cross!
Any chance someone could let me know if I have the correct values for H(million) and H(ten million)?
[(5,30),(10,138),(1000,1177848),(1000000,1176221685648),(10000000,117621891442704)]
Thanks!
Any chance someone could let me know if I have the correct values for H(million) and H(ten million)?
[(5,30),(10,138),(1000,1177848),(1000000,1176221685648),(10000000,117621891442704)]
Thanks!
Re: Problem 351
Silly me, I was using Float when I should have been using Double. Sometimes, it's easy to get lulled into complacency when using a language with native big integers...
Re: Problem 351
Hello all,
Maybe someone could enlighten me on this one: the PDF solution sheet for this problem describes several possible algorithms of varying efficiency, yet they mainly seem to rely on an array containing all the required integer values, i.e. 10^8 numbers in this case.
On my system and using C/C++, defining an array this size immediately causes a 'Segmentation fault'  and the number spaces required only get larger on some of the more difficult problems on PE.
Am I missing something?
Thanks in advance for any input!
Claude
Maybe someone could enlighten me on this one: the PDF solution sheet for this problem describes several possible algorithms of varying efficiency, yet they mainly seem to rely on an array containing all the required integer values, i.e. 10^8 numbers in this case.
On my system and using C/C++, defining an array this size immediately causes a 'Segmentation fault'  and the number spaces required only get larger on some of the more difficult problems on PE.
Am I missing something?
Thanks in advance for any input!
Claude
Re: Problem 351
Do you know the difference between the stack and heap memory? Do you know how to use standard library containers such as std::vector?
Last edited by jaap on Fri Nov 16, 2018 1:37 pm, edited 1 time in total.
_{Jaap's Puzzle Page}
Re: Problem 351
Cheers Jaap,
I'm afraid I'll have to confess my ignorance on the first question (I'll google that though). I do use vectors, yes, but I would have thought it would pose problems of efficiency too as it will take up a lot of memory.
I'll try that approach over the weekend though and see what happens
Claude
I'm afraid I'll have to confess my ignorance on the first question (I'll google that though). I do use vectors, yes, but I would have thought it would pose problems of efficiency too as it will take up a lot of memory.
I'll try that approach over the weekend though and see what happens
Claude
Re: Problem 351
I hope that is where your trouble lies. Basically, if you need to use lots of memory (more than the stack provides), you have to allocate it yourself from the heap. You can do it the oldfashioned C way with malloc/free, or the slightly more C++ way with new[]/delete[], or just use containers like std::vector. Use the smallest integer type you need. For example, with 32bit integers allocating 10^8 of them takes 4*10^8 bytes, or about 400 Mb. This should be fine on any modern PC.DeKlod wrote: ↑Fri Nov 16, 2018 12:00 pmCheers Jaap,
I'm afraid I'll have to confess my ignorance on the first question (I'll google that though). I do use vectors, yes, but I would have thought it would pose problems of efficiency too as it will take up a lot of memory.
I'll try that approach over the weekend though and see what happens
Claude
_{Jaap's Puzzle Page}
Re: Problem 351
Thanks for that, jaap!
Just one last question, if I may: is there any other obvious technique if you really need large quantities of data? Imagine a sieve for primes up to  say  10^12. Vectors of type bool seem to be fine up to about 10^10 but not further. So I guess that's where you need to change tack and do something completely different, right?
Not asking for hints, as such, just wanting to avoid long barking sessions up the wrong tree...
Cheers,
Claude
Just one last question, if I may: is there any other obvious technique if you really need large quantities of data? Imagine a sieve for primes up to  say  10^12. Vectors of type bool seem to be fine up to about 10^10 but not further. So I guess that's where you need to change tack and do something completely different, right?
Not asking for hints, as such, just wanting to avoid long barking sessions up the wrong tree...
Cheers,
Claude
Re: Problem 351
If you ever need more than, say, 600MB of data, then you are probably doing it wrong. You are either using the wrong solving method, or maybe you just don't need to have all of that data in memory at the same time.
_{Jaap's Puzzle Page}