Problem 212
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.
-
pjt33
- Posts: 142
- Joined: Mon Oct 06, 2008 6:14 pm
Problem 212
The value I get for the sum of the volumes of the first 100 cuboids is less than the hint value given for the sum of their union, so I must have a bug in my lagged Fibonacci generator. However, I can't see anything which looks wrong, and it produces the first two cuboids correctly. Could someone please post C100 for comparison? I make it {(6055,553,2105),(339,66,283)}.
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 212 - lagged Fibonacci generator
Here are what I think are 99-101:pjt33 wrote:The value I get for the sum of the volumes of the first 100 cuboids is less than the hint value given for the sum of their union, so I must have a bug in my lagged Fibonacci generator. However, I can't see anything which looks wrong, and it produces the first two cuboids correctly. Could someone please post C100 for comparison? I make it {(6055,553,2105),(339,66,283)}.
1119 3181 374 232 297 121
8487 1033 5529 307 337 46
6088 4299 4383 44 34 129
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 212 - lagged Fibonacci generator
I agree with jaap.
Do you get
*Lagged> cube 20
[2323,1925,7281,154,87,30]
and
*Lagged> cube 24
[312,6798,2104,138,325,67]
?
In other words, I suspect overflow.
Do you get
*Lagged> cube 20
[2323,1925,7281,154,87,30]
and
*Lagged> cube 24
[312,6798,2104,138,325,67]
?
In other words, I suspect overflow.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
pjt33
- Posts: 142
- Joined: Mon Oct 06, 2008 6:14 pm
Re: Problem 212 - lagged Fibonacci generator
Daniel, you're spot on about the overflow. Thanks, both of you.
- DNS
- Posts: 30
- Joined: Thu Oct 16, 2008 9:32 am
- Location: Ukraine, Nikolaev
Re: Problem 212 - lagged Fibonacci generator
A method I design is sloooow. For 100 cuboids time is about 0.5 min...
Can somebody confirm n=1579 V=13022800300 ?
2 x 2 = 4 = true
- Georg
- Posts: 157
- Joined: Mon Jan 21, 2008 7:00 am
- Location: Mannheim, Germany
- Contact:
Re: Problem 212 - lagged Fibonacci generator
Confirmed.DNS wrote:Can somebody confirm n=1579 V=13022800300 ?
- DNS
- Posts: 30
- Joined: Thu Oct 16, 2008 9:32 am
- Location: Ukraine, Nikolaev
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
Re: Problem 212 - lagged Fibonacci generator
Just a bit slowDNS wrote:My way is not wrong
I don't know what programming language you are using, but my experience with C++ is that sometimes a significant speed boost can be gained by using a compiler that performs optimisations. I've seen programs I made run up to 10 times faster by allowing the optimisations.. Recursive algorithms are the best target
- DNS
- Posts: 30
- Joined: Thu Oct 16, 2008 9:32 am
- Location: Ukraine, Nikolaev
Re: Problem 212 - lagged Fibonacci generator
Thanks, stijn263, for the idea.
I use C++ 5.02 from Borland, my PC is Duron 1.4, 512Mb.
As I note, when __int64 type is used, program runs ~10 times slower in comparision with long type. But long type is short (
) for preserv a result.
Sometimes I use Ruby, but it is 10 times more slow than C++ with __int64
I use C++ 5.02 from Borland, my PC is Duron 1.4, 512Mb.
As I note, when __int64 type is used, program runs ~10 times slower in comparision with long type. But long type is short (
Sometimes I use Ruby, but it is 10 times more slow than C++ with __int64
2 x 2 = 4 = true
- JamieCamardelle
- Posts: 20
- Joined: Wed May 14, 2008 5:34 am
Problem 212
For problem 212, combined volume of cuboids, I wrote code that works great for some test sets of cuboids I built. It uses a generalized DeMoivre’s theorem. Even though my test sets are complex, with many different configurations of overlap between cuboids, and the code captures the overlaps and adds or subtracts intersecting volumes as appropriate, it doesn’t capture any overlap between the first 100 cuboids generated for the problem.
I must assume there is some overlap between at least two cuboids in the first 100, otherwise the combined volume of the cuboids would be 776975023 instead of 723581599 given in the problem explanation.
If someone could please tell me the positions of at least two cuboids that overlap among the first 100, I can debug and hopefully settle the issue and solve the problem.
I really appreciate anyone's help.
PS - I assume my cuboid generator is correct since my first two cuboids match the ones given in the problem explanation.
I must assume there is some overlap between at least two cuboids in the first 100, otherwise the combined volume of the cuboids would be 776975023 instead of 723581599 given in the problem explanation.
If someone could please tell me the positions of at least two cuboids that overlap among the first 100, I can debug and hopefully settle the issue and solve the problem.
I really appreciate anyone's help.
PS - I assume my cuboid generator is correct since my first two cuboids match the ones given in the problem explanation.
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
Re: Problem 212
Actually, I get 726218359 without taking the overlapping in account..
There's an intersection with origin at (9872,3710,7557) between cuboids 58 and 67 (zero based indices).
Also, you could still have an integer overflow problem, despite the fact that your first two cuboids are correct..
There's an intersection with origin at (9872,3710,7557) between cuboids 58 and 67 (zero based indices).
Also, you could still have an integer overflow problem, despite the fact that your first two cuboids are correct..
- Tommy137
- Posts: 238
- Joined: Sun Feb 24, 2008 6:02 pm
- Location: Cologne, Germany
- Contact:
- JamieCamardelle
- Posts: 20
- Joined: Wed May 14, 2008 5:34 am
Re: Problem 212
Thanks for your help. Maybe I have the integer overflow problem.
With indices starting at 1, I have: C[[58]]={{4223, 2059, 4343}, {349, 205, 175}},
C[[67]]={{4223, 2353, 7199}, {251, 229, 190}}
I guess that your C[[58]], C[[67]] is my C[[59]], C[[68]].
I have: C[[59]]={{8799, 3953, 3807}, {202, 256, 70}}, C[[68]]={{4583, 3639, 9663}, {305, 119, 67}}
If my results don't match yours, I'll guess it is a problem with my cuboid list.
With indices starting at 1, I have: C[[58]]={{4223, 2059, 4343}, {349, 205, 175}},
C[[67]]={{4223, 2353, 7199}, {251, 229, 190}}
I guess that your C[[58]], C[[67]] is my C[[59]], C[[68]].
I have: C[[59]]={{8799, 3953, 3807}, {202, 256, 70}}, C[[68]]={{4583, 3639, 9663}, {305, 119, 67}}
If my results don't match yours, I'll guess it is a problem with my cuboid list.
- JamieCamardelle
- Posts: 20
- Joined: Wed May 14, 2008 5:34 am
Re: Problem 212
I get s[55]=764463Tommy137 wrote:What do you get for S55?
I get C[[55]]={{5903, 857, 9503}, {164, 336, 63}}
- Tommy137
- Posts: 238
- Joined: Sun Feb 24, 2008 6:02 pm
- Location: Cologne, Germany
- Contact:
Re: Problem 212
s[55] is correct, but your cuboid-values for 55, 59 and 68 aren't...JamieCamardelle wrote:I get s[55]=764463Tommy137 wrote:What do you get for S55?
I get C[[55]]={{5903, 857, 9503}, {164, 336, 63}}

- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
- JamieCamardelle
- Posts: 20
- Joined: Wed May 14, 2008 5:34 am
Re: Problem 212
Thanks for the help. I was able to figure out that the problem was in my cuboid list, and not in my volume computing algorithm. My mistake was dumber than I thought - not integer overflow, but incorrectly computing all sk for k > 55.
-
sivakd
- Posts: 217
- Joined: Fri Jul 17, 2009 9:37 am
- Location: California, USA
- Contact:
Re: Problem 212
Should the wording
x_(0) ≤ X ≤ x_(0)+dx, y_(0) ≤ Y ≤ y_(0)+dy and z_(0) ≤ Z ≤ z_(0)+dz
have been
x_(0) ≤ X < x_(0)+dx, y_(0) ≤ Y < y_(0)+dy and z_(0) ≤ Z < z_(0)+dz
for this problem? Otherwise, how can the volume be dx*dy*dz?
Say, {(0,0,0),(1,1,1)} would have a volume of 8 with the former definition and 1 with the later. Isn't it?
Anyway, I solved this problem, but wasted a lot of time on this and only by looking at the non-overlap volume in the above post I figured out what I was doing wrong as per the expected definition of the problem.
x_(0) ≤ X ≤ x_(0)+dx, y_(0) ≤ Y ≤ y_(0)+dy and z_(0) ≤ Z ≤ z_(0)+dz
have been
x_(0) ≤ X < x_(0)+dx, y_(0) ≤ Y < y_(0)+dy and z_(0) ≤ Z < z_(0)+dz
for this problem? Otherwise, how can the volume be dx*dy*dz?
Say, {(0,0,0),(1,1,1)} would have a volume of 8 with the former definition and 1 with the later. Isn't it?
Anyway, I solved this problem, but wasted a lot of time on this and only by looking at the non-overlap volume in the above post I figured out what I was doing wrong as per the expected definition of the problem.

puzzle is a euphemism for lack of clarity
- hk
- Administrator
- Posts: 12842
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 212
{(0,0,0),(1,1,1)} and x_(0) ≤ X ≤ x_(0)+dx, y_(0) ≤ Y ≤ y_(0)+dy and z_(0) ≤ Z ≤ z_(0)+dzsivakd wrote:Should the wording
x_(0) ≤ X ≤ x_(0)+dx, y_(0) ≤ Y ≤ y_(0)+dy and z_(0) ≤ Z ≤ z_(0)+dz
have been
x_(0) ≤ X < x_(0)+dx, y_(0) ≤ Y < y_(0)+dy and z_(0) ≤ Z < z_(0)+dz
for this problem? Otherwise, how can the volume be dx*dy*dz?
Say, {(0,0,0),(1,1,1)} would have a volume of 8 with the former definition and 1 with the later. Isn't it?
represents a cube with side 1 with all its surfaces.
{(0,0,0),(1,1,1)} and x_(0) ≤ X < x_(0)+dx, y_(0) ≤ Y < y_(0)+dy and z_(0) ≤ Z < z_(0)+dz
represents a cube with side 1 with three of its 6 surfaces.
Both have volume 1.

War ruins the life and health of untold numbers of innocent children.
- Lord_Farin
- Posts: 239
- Joined: Wed Jul 01, 2009 10:43 am
- Location: Netherlands
Re: Problem 212
You may want to notice that the volume of a cuboid is not the same as the amount of lattice points contained in it. That is what led to your confusion, I believe. Since planes have volume zero in 3D, it does not matter if we include the boundary of the cuboid or not: the volume stays the same.

