Problem 009
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.
- nicolas.patrois
- Posts: 118
- Joined: Fri Jul 26, 2013 4:54 pm
- Contact:
-
adarshbl
- Posts: 3
- Joined: Sun Dec 27, 2015 11:37 am
Re: Problem 009
Hi, I am new to this forum. And i need help on this question. I am generating Triplets starting from c = 1000 till c = 5 but when i sum up the triplets a+b+c, none if the triplets add upto 1000. It is 1008 or 9** something. Can anyone please help me on whats wrong with my approach.
Postby quintic » Fri Apr 21, 2006 1:56 am
Thanks & Regards,
Ady
Postby quintic » Fri Apr 21, 2006 1:56 am
Thanks & Regards,
Ady
- Georg
- Posts: 157
- Joined: Mon Jan 21, 2008 7:00 am
- Location: Mannheim, Germany
- Contact:
-
adarshbl
- Posts: 3
- Joined: Sun Dec 27, 2015 11:37 am
- Georg
- Posts: 157
- Joined: Mon Jan 21, 2008 7:00 am
- Location: Mannheim, Germany
- Contact:
-
AwesomeMeAY
- Posts: 1
- Joined: Wed Aug 28, 2019 1:56 am
Problem #9
I have a question on Project Euler problem 9. Do the three integers have to be consecutive?
-
philiplu
- Posts: 92
- Joined: Wed Aug 02, 2017 8:51 pm
- Location: Redmond, WA, USA
Re: Problem #9
No, and in fact they couldn't possibly be. If a, b, c are all consecutive, then a+b+c = a+(a+1)+(a+2) = 3a+3, which is a multiple of 3. 1000 is not a multiple of 3, so it can't be the sum of 3 consecutive integers.

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
Hello Project Euler Community,
I'm soooo stuck on problem 9
I'm new to programming, been learning Python since April as part of a OU Computing & IT degree. Also I don't have much of a maths background, been getting back into that with my course too. I'm really enjoying the challenge of Project Euler but I've got stuck.
On problem 9 I think it's mostly the maths I'm stuck at rather than the code. I've had to research pythagorean triplets and how to find them. I've tried 4 different formulas and none of them are coming up with a triplet that adds up to 1000. I feel like there must be something maths wise I'm missing coz I'm confident my code is working. Unless my while loop has the wrong condition. I really don't want the solution but hoped someone might be able to point me in the right direction. I also don't want to break any rules by saying too much on this post. Can I say what methods I've used to find the triplets?
Thanks in advance for any pointers
Becks
I'm soooo stuck on problem 9
I'm new to programming, been learning Python since April as part of a OU Computing & IT degree. Also I don't have much of a maths background, been getting back into that with my course too. I'm really enjoying the challenge of Project Euler but I've got stuck.
On problem 9 I think it's mostly the maths I'm stuck at rather than the code. I've had to research pythagorean triplets and how to find them. I've tried 4 different formulas and none of them are coming up with a triplet that adds up to 1000. I feel like there must be something maths wise I'm missing coz I'm confident my code is working. Unless my while loop has the wrong condition. I really don't want the solution but hoped someone might be able to point me in the right direction. I also don't want to break any rules by saying too much on this post. Can I say what methods I've used to find the triplets?
Thanks in advance for any pointers
Becks

- kenbrooker
- Posts: 187
- Joined: Mon Feb 19, 2018 3:05 am
- Location: Northern California, USA
Re: Problem 009
The 3-4-5 triangle is the classic Pythagorean Triplet...
Can any of your approaches find that one,
using the sum of the sides = 12?
Can any of your approaches find that one,
using the sum of the sides = 12?
"Good Judgment comes from Experience;
Experience comes from Bad Judgment..."

Experience comes from Bad Judgment..."

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
Hi kenbrooker,
All 4 of my approaches can find that one. One of my approaches uses those 3 numbers as my start point, the other 3 don't.
All 4 of my approaches can find that one. One of my approaches uses those 3 numbers as my start point, the other 3 don't.

- kenbrooker
- Posts: 187
- Joined: Mon Feb 19, 2018 3:05 am
- Location: Northern California, USA
Re: Problem 009
On the approach using those three numbers as a starting point, yielding a sum of 12,Bee_Reay wrote: Fri Jul 17, 2020 12:03 am All 4 of my approaches can find that one. One of my approaches uses those 3 numbers as my start point, the other 3 don't.
maybe you need to increase the allowable size of the three numbers
which will yield a sum of 1000?
Or, if that makes no sense, please send me a
PM with your code?
"Good Judgment comes from Experience;
Experience comes from Bad Judgment..."

Experience comes from Bad Judgment..."

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
hmmmm I've been mulling this today.
I don't have a limit on the allowable size of the numbers - only on the sum so my while loop stops. I wonder if maybe I'm doing things back to front. Perhaps I need to work from the sum backwards somehow? I'm just not sure of what the relationship between the 3 numbers can be other than the formulas I've tried.
I don't have a limit on the allowable size of the numbers - only on the sum so my while loop stops. I wonder if maybe I'm doing things back to front. Perhaps I need to work from the sum backwards somehow? I'm just not sure of what the relationship between the 3 numbers can be other than the formulas I've tried.

- kenbrooker
- Posts: 187
- Joined: Mon Feb 19, 2018 3:05 am
- Location: Northern California, USA
Re: Problem 009
There are any number of triangles where
the three sides sum to 1000 but
only one right triangle...
the three sides sum to 1000 but
only one right triangle...
"Good Judgment comes from Experience;
Experience comes from Bad Judgment..."

Experience comes from Bad Judgment..."

-
TheBonobo4
- Posts: 17
- Joined: Sun Jul 12, 2015 9:51 pm
Re: Problem 009
You know that a<b<c, and a+b+c=1000, and a^2+b^2=c^2. So you know that a is less than or equal to 332. If that helps.Bee_Reay wrote: Fri Jul 17, 2020 10:58 pm hmmmm I've been mulling this today.
I don't have a limit on the allowable size of the numbers - only on the sum so my while loop stops. I wonder if maybe I'm doing things back to front. Perhaps I need to work from the sum backwards somehow? I'm just not sure of what the relationship between the 3 numbers can be other than the formulas I've tried.
And yes, there is exactly one right triangle that fits all the required properties.

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
Thanks for the help
I've ended up solving it with the brute force method and a lot of online help. I didn't copy any code but couldn't have solved it alone. Not so pleased with myself but hopefully it'll be a learning experience because it's not the method I would've automatically gone for and now I know that's one way to go about it. I would normally look for the method linked to how it might be solved manually and transferred that to code but that didn't work for me in this case.
And on to the next problem...
I've ended up solving it with the brute force method and a lot of online help. I didn't copy any code but couldn't have solved it alone. Not so pleased with myself but hopefully it'll be a learning experience because it's not the method I would've automatically gone for and now I know that's one way to go about it. I would normally look for the method linked to how it might be solved manually and transferred that to code but that didn't work for me in this case.
And on to the next problem...

-
TheBonobo4
- Posts: 17
- Joined: Sun Jul 12, 2015 9:51 pm
Re: Problem 009
Congratulations. How many total problems have you solved now?
Also, feel free to PM me the code you used if you want, and may I ask how long it took to run?
Also, feel free to PM me the code you used if you want, and may I ask how long it took to run?

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
Thanks
I've now solved the first 10 problems. Just got problem 10 done tonight once I found a way to check for large prime numbers more quickly. How many have you solved?
Problem 11 looks
I think it could be beyond me tbh
I don't know how to time it precisely but it was very quick.
I've now solved the first 10 problems. Just got problem 10 done tonight once I found a way to check for large prime numbers more quickly. How many have you solved?
Problem 11 looks
I don't know how to time it precisely but it was very quick.

-
TheBonobo4
- Posts: 17
- Joined: Sun Jul 12, 2015 9:51 pm
Re: Problem 009
If you look in my forum signature here it updates automatically whenever I solve a problem, you can edit your forum signature to do the same as well.
In any case I've solved 58 so far, I started about November 2014, but I've taken breaks in that time, and I haven't solved them in order. In fact I'd advise against doing so, simply because problems aren't in order of difficulty, and it is good to learn from older problems. Example, if you've just solved a problem about primes, you might want to try another on primes rather than one on something completely different like geometry.
I also have to admit there are problems I solved ages ago that I've since forgotten how I solved exactly.
In any case I've solved 58 so far, I started about November 2014, but I've taken breaks in that time, and I haven't solved them in order. In fact I'd advise against doing so, simply because problems aren't in order of difficulty, and it is good to learn from older problems. Example, if you've just solved a problem about primes, you might want to try another on primes rather than one on something completely different like geometry.
I also have to admit there are problems I solved ages ago that I've since forgotten how I solved exactly.

- Bee_Reay
- Posts: 7
- Joined: Thu Jul 16, 2020 3:20 pm
- Location: Scotland, UK
Re: Problem 009
Hi,
Thanks for the tips
I've sorted my signature. I hadn't even noticed other people had that on their signature - it's pretty cool. I've got to get to at least level 1 purely for my signature's sake so I'll take your advice about doing them out of order.
I also learned how to time my program. My working code for problem 9 took 0.23 sec. It varies, I assume depending on what else my laptop is doing at the same time. Gonna go time my other ones now
Thanks for the tips
I also learned how to time my program. My working code for problem 9 took 0.23 sec. It varies, I assume depending on what else my laptop is doing at the same time. Gonna go time my other ones now

