+ 17

CODING CHALLENGE #5!! Pythagorean Triples

If you didn't know, Pythagorean Triples are three positive integers a,b and c such that a2 +b2 = c2. That is the Pythagoras theorem. Try to make an array that contains all the Pythagorean triples up to 100. Make sure you remove the duplicates. 3,4,5... You might have in your list 3,4,5 and 4,3,5... Try to remove the duplicates.. No google or stackoverflow.com Good luck and have fun https://code.sololearn.com/ciMGimqauCkT/?ref=app

17th Apr 2017, 4:17 PM
Gami
Gami - avatar
8 Réponses
+ 10
https://code.sololearn.com/cI2Jibbg5XC6/#py UPD: Now it is sorted and nice with no repetitions. Somehow it shows more triples than @Ashwani 's code, even when I exclude the ones with the third number >100. Let's figure out what is the reason for this
17th Apr 2017, 6:27 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 14
Congratulations @Dinmukhamed!! I like all of them but yours is fastest @Ashwani Yours is the best because it is visually good
17th Apr 2017, 6:28 PM
Gami
Gami - avatar
+ 9
@Dinmukhamed I already corrected the code. You can check the updated one. I hope this one contains all..If not you can still let me know. I see nos. greater than 100 also in your output, i think that should be taken care..Not so important though.. Great code..Best of luck ✌️👍
17th Apr 2017, 6:38 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 8
My version with variable input of NOS. default 100. https://code.sololearn.com/WhTslie3DOHC/?ref=app
17th Apr 2017, 5:18 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 8
@Gami Thanks for the appreciation ☺️
17th Apr 2017, 6:39 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 7
Ashwani, your code for some reason doesn't include some of the triples like: 13 84 85 14 48 50 16 63 65 My guess is that it removes all the repetitions based on the assumption that there cannot be more than one triple for every hypothenuse length. But mathematically this assumption is wrong. Try for example 14 48 50 and 30 40 50. So you should fix that point. Nice GUI by the way
17th Apr 2017, 6:34 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 2
I had to take it a bit like competition. My goal was to create a fast yet simple code.... I think I accomplished both. I don't have any graphics there, but well... I don't intend to program a website. Only a javascript :) https://code.sololearn.com/WKvInnHSWH3F/?ref=app And here is the python variation. Even shorter than javascript due to lack of empty lines (without them it's 10 lines of code as well though). No need to deal with duplicate triplets or anything like that. I just bypassed them. https://code.sololearn.com/cVZik9Ara4rW/?ref=app
18th Apr 2017, 4:37 PM
Richard Urbanec
Richard Urbanec - avatar