Pythagoras Triplet

Hi,
There is more than 1 solution for a given 1 leg in a right-angle triangle.
Ex: if given 60, then both these sets form right angle triangle: (60,80,100),(60,91,109)

I think I solved the problem, but the test case is not matching because it didn’t consider all possible solutions as the correct answers.

I got 2 failed test cases. Can you verify those test cases against my code and check if my solution forms right triangle or not using this website(https://www.mathwarehouse.com/triangle-calculator/online.php) or Pythagoras formula?

If my solution is wrong, then I will unlock test cases to check the issue. But, if it’s right, please consider awarding points to my solution.

Thanks,
Su

Hey @sudhaismyname , The algorithm that you have used here is wrong . Consider the case 41 , 40 , 9 (Which are pythagorean triplets) You will be able to see the error.
I have cleared it to you in the inbox as well
Happy coding :slight_smile:

Thanks Ankit. I marked doubt as solved in the course and I couldn’t find an option to reply.
As suggested, I tried with small number 4 as input, and my program failed.
I found the hint video in the course helpful and will try it.

Appreciate your patience to read and understand my code. Thanks for helping. :slight_smile:

1 Like