Problem 039
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 039
Problem 39 reads like this:
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p<1000, is the number of solutions maximised?
Now as i see it, the sides of a right triangle must match the wellknown pythagorean a^2+b^2=c^2
However the wording of the question throws me off when it says "with integral length sides"...I know integral is generally used in the realm of calculus, something I haven't really dabbled in since high school (i'm now out of college), but I fail to see how it relates to the problem at hand. Am I looking for perimeter values with special rules for their side lengths, or are any side lengths that match the pythagorean theorem fair game?
If I need a special rule for it, what does "integral length sides" mean?
Thanks for the help
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p<1000, is the number of solutions maximised?
Now as i see it, the sides of a right triangle must match the wellknown pythagorean a^2+b^2=c^2
However the wording of the question throws me off when it says "with integral length sides"...I know integral is generally used in the realm of calculus, something I haven't really dabbled in since high school (i'm now out of college), but I fail to see how it relates to the problem at hand. Am I looking for perimeter values with special rules for their side lengths, or are any side lengths that match the pythagorean theorem fair game?
If I need a special rule for it, what does "integral length sides" mean?
Thanks for the help
Re: Problem 39  Integral Length Sides?
They must be integers.nZifnab wrote:what does "integral length sides" mean?
for($"=@_=split??,"Jrsk an treP rehlohacteu,";$";$\="\r"){$\.=$.=chr
32+95*rand,$_$"or$.ne$_[$"%2?$"1:$"]&&$"++for++$..$";print}<>
32+95*rand,$_$"or$.ne$_[$"%2?$"1:$"]&&$"++for++$..$";print}<>
Re: Problem 39  Integral Length Sides?
oh...dur.funktio wrote:They must be integers.nZifnab wrote:what does "integral length sides" mean?
Thanks :p
Re: Problem 39  Integral Length Sides?
To the moderators: there is an offbyone error in the problem itself :
 The summary of this problem says p ≤ 1000
 The long description of this problem says p < 1000
Re: Problem 39  Integral Length Sides?
Thanks for pointing that out. Correction made.macfreek wrote:To the moderators: there is an offbyone error in the problem itself :Of course, the solution remains the same.
 The summary of this problem says p ≤ 1000
 The long description of this problem says p < 1000
When you assume something, you risk being wrong half the time.
Re: Problem 039
removed posted solution
I have an efficient solution to this problem that was not posted by anyone (I believe) in the solutions, since the thread is locked, is there anyway I can get it added?
I have an efficient solution to this problem that was not posted by anyone (I believe) in the solutions, since the thread is locked, is there anyway I can get it added?
Last edited by eay on Thu Oct 22, 2009 3:36 pm, edited 5 times in total.
 elendiastarman
 Posts: 410
 Joined: Sat Dec 22, 2007 8:15 pm
Re: Problem 039
Erm...you should edit that out. Solutions + open forum = baaaaaaaaad....
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Re: Problem 039
I'm now stump on this problem. Are we supposed to figure out what value below or equal to 1000 has the most count? In addition, does "integral length sides only" means ones that are Pythagorean triples which obviously goes with integers only?
Re: Problem 039
Yes. The example shows a "count" of 3 for the right angle triangles with integral length sides having a perimeter of 120. The required answer is the value of that perimeter, not to exceed 1000, which would have the highest count.JMW1994 wrote:I'm now stump on this problem. Are we supposed to figure out what value below or equal to 1000 has the most count?
YesIn addition, does "integral length sides only" means ones that are Pythagorean triples which obviously goes with integers only?
When you assume something, you risk being wrong half the time.

 Posts: 3
 Joined: Sun Aug 19, 2018 9:49 pm
Re: Problem 039
Question about this:
The problem description says the solutions (for the example) are
{20,48,52}, {24,45,51}, {30,40,50}
But, if we allow degenerate triangles, then
{60,0, 60} and {0,60,60}
are valid (or, really, just pick one of them.)
Are degenerate triangles not valid, or is the description incorrect?
For any given perimeter it only adds two (one) possibilities, but perhaps the text of the question should be clarified to specify "nonzero integers."
The problem description says the solutions (for the example) are
{20,48,52}, {24,45,51}, {30,40,50}
But, if we allow degenerate triangles, then
{60,0, 60} and {0,60,60}
are valid (or, really, just pick one of them.)
Are degenerate triangles not valid, or is the description incorrect?
For any given perimeter it only adds two (one) possibilities, but perhaps the text of the question should be clarified to specify "nonzero integers."
Last edited by davidlively on Sun Aug 19, 2018 10:44 pm, edited 1 time in total.
Re: Problem 039
Right angle triangle should be clear enough.
Only 1 angle of a degenerated triangle can be determined exactly: 0° between the two identical sides.
The other two angles are undetermined.
In any problem description, corner cases are named extra. (Integer 0, degenerated polygons,...)
But this does not change the solution of this problem.
And in addition, your additional examples are identical!
Only 1 angle of a degenerated triangle can be determined exactly: 0° between the two identical sides.
The other two angles are undetermined.
In any problem description, corner cases are named extra. (Integer 0, degenerated polygons,...)
But this does not change the solution of this problem.
And in addition, your additional examples are identical!

 Posts: 3
 Joined: Sun Aug 19, 2018 9:49 pm
Re: Problem 039
Thanks for the information, and that'll be helpful on other problems.
However, they're *not* geometrically identical. One points north, the other points east. (Depending on your perspective, I guess!)
(Qualifier: I'm a graphics programmer, so these things come up. A lot.)
Thanks again.
However, they're *not* geometrically identical. One points north, the other points east. (Depending on your perspective, I guess!)
(Qualifier: I'm a graphics programmer, so these things come up. A lot.)
Thanks again.
Re: Problem 039
Going back in time a bit here re. #39 which I solved quite some time ago. I'm currently stuck with #75 which currently I'm treating as a version of #39. So I revisited my code for #39 and I found something I found with relevance to why I may be stuck, and wondering how I managed to get the right solution for #39 when I did.
Euclid's formula states that "..given an arbitrary pair of integers m and n with m > n > 0... the integers a = k(m^2 − n^2) , b = k(2 m n), c = k(m^2 + n^2) form a Pythagorean triple. The triple generated by Euclid's formula is primitive if and only if m and n are coprime and not both odd."
The example given in the text for #39 states that there are 3 solutions when p = a + b + c = 120.
Now, this is true for p = 120 when not checking m, n are coprime (therefore not primitive), but the correct solution for the whole problem is only found when you do check m, n are coprime. In that case only 2 solutions for p = 120 appear.
Is the wording of the problem intentional? I appreciate there are other ways of solving the problem where this won't come up.
Euclid's formula states that "..given an arbitrary pair of integers m and n with m > n > 0... the integers a = k(m^2 − n^2) , b = k(2 m n), c = k(m^2 + n^2) form a Pythagorean triple. The triple generated by Euclid's formula is primitive if and only if m and n are coprime and not both odd."
The example given in the text for #39 states that there are 3 solutions when p = a + b + c = 120.
Now, this is true for p = 120 when not checking m, n are coprime (therefore not primitive), but the correct solution for the whole problem is only found when you do check m, n are coprime. In that case only 2 solutions for p = 120 appear.
Is the wording of the problem intentional? I appreciate there are other ways of solving the problem where this won't come up.
Re: Problem 039
It's not stated that the solutions must be primitive.
In fact none of the given solutions is primitive:
{20,48,52}=4*(5,12,13)
{24,45,51}=3*(8,15,17)
{30,40,50}=10*(3,4,5)
In fact none of the given solutions is primitive:
{20,48,52}=4*(5,12,13)
{24,45,51}=3*(8,15,17)
{30,40,50}=10*(3,4,5)
Re: Problem 039
Ah.. sorry I probably shouldn't have stressed the primitive (given that k is involved). I misworded that.
However I still get the correct solution when checking m, n are coprime, but only 2 solutions for p=120. Yet the the problem suggests 3 solutions for p=120 which I only get when I don't check m, n are coprime.
Hmm.. The missing solution I get for p=120 when I don't check coprime is {20,48,52}. But I get that for k=1, not 4 as you show. Ok I need to check my code again and find out why I don't get {20,48,52}=4*(5,12,13) when I am checking coprime.
In addition, and probably also due to this, I never get a result for p=30, which I haven't been able to track down.
It's a miracle this ever worked the first time!
Thanks hk.
However I still get the correct solution when checking m, n are coprime, but only 2 solutions for p=120. Yet the the problem suggests 3 solutions for p=120 which I only get when I don't check m, n are coprime.
Hmm.. The missing solution I get for p=120 when I don't check coprime is {20,48,52}. But I get that for k=1, not 4 as you show. Ok I need to check my code again and find out why I don't get {20,48,52}=4*(5,12,13) when I am checking coprime.
In addition, and probably also due to this, I never get a result for p=30, which I haven't been able to track down.
It's a miracle this ever worked the first time!
Thanks hk.
Re: Problem 039
There is another condition: m and n should have different parity.
The coprime triple that generates (5,12,13) is m=3 and n=2
The other set (m,n) is 5,1: 25+1=26. 251=24 and 2*5*1=10 which gives 10,24,26. But because m and n are both odd it's not a valid coprime triple.
The coprime triple that generates (5,12,13) is m=3 and n=2
The other set (m,n) is 5,1: 25+1=26. 251=24 and 2*5*1=10 which gives 10,24,26. But because m and n are both odd it's not a valid coprime triple.
Re: Problem 039
Agreed. I think I'm generating m, n incorrectly. I thought I was, but probably didn't check thoroughly enough. I suspect I'm skipping valid pairs.
Re: Problem 039
Yes, skipping valid m,n pairs. All fixed now and onto #75 with that fix.
Thanks for the pointers, hk. Much appreciated.
Thanks for the pointers, hk. Much appreciated.