Given four different positive numbers, a, b, c and d, provided in increasing order: a < b < c < d, find if any three of them comprise sides of a right-angled triangle. Return true if they do, otherwise return false .
Solution Stats
Problem Comments
12 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers5073
Suggested Problems
-
Find the sum of all the numbers of the input vector
54109 Solvers
-
Given a window, how many subsets of a vector sum positive
871 Solvers
-
644 Solvers
-
Basics: 'Find the eigenvalues of given matrix
438 Solvers
-
Try 1.5.4: Celsius to Fahrenheit
867 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
See Problem 1550 Can I make a right triangle ?
Thanks Tanya, have enjoyed these.
if (a==2|a==3)
flag=true;
end
The cases are very limited to make such a code valid
Thanks, enjoyed these.
I really liked this problem!
niceee
brainstormed
any insight into handling the case where one of the side lengths is irrational and rounding error in the approximation causes a false negative to be returned?
for example - Test 7
roundup the numbers before comparing
I think for Test-7 , problem creator @Tanya should add "~" to the "flag_correct" part of the line:
assert(isequal(isTherePythagoreanTriple(a, b, c, d),flag_correct))
so it should be changed to :
assert(isequal(isTherePythagoreanTriple(a, b, c, d),~flag_correct))
Pythagorean triplets are taken as positive integers , one of the test case uses irrational number for inputs ! I wish the test creator
@Tanya Morton makes appropriate change as suggested by @Sophia
yeah took me a minute to figure out the rounding bit