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.
function flag = isTherePythagoreanTriple(a, b, c, d)
flag = false;
com_bin = nchoosek([a b c d],3);
com_bin = com_bin(:,1) .^ 2 + com_bin(:,2) .^ 2 == com_bin(:,3) .^ 2;
flag = logical(sum(com_bin));
end
function flag = isTherePythagoreanTriple(a, b, c, d)
x=[logical(a^2+b^2==d^2) logical(a^2+c^2==d^2) logical(b^2+c^2==d^2) logical(a^2+b^2==c^2)];
flag = any(x);
end
M=[a,b,c,d]
c=nchoosek(M,3);
c=c(sum(c(:,1:2).^2,2)-c(:,3).^2==0,:);
if isempty(c)
flag = false;
else
flag = true;
end
function flag = isTherePythagoreanTriple(a, b, c, d)
flag = false;
com_bin = nchoosek([a b c d],3);
com_bin = com_bin(:,1) .^ 2 + com_bin(:,2) .^ 2 == com_bin(:,3) .^ 2;
flag = logical(sum(com_bin));
end
This is not a valid solution to this puzzle!!
This is a smart solution that is not cheating the system.
Logical enough!
Great work!
Lol saying great work on your own solution :P
Great work :)
Haha that's how we roll!
why the leading solution size is always 10, how could that possible?
Yeah, I know this is cheating, taking advantage of the limited test suite. I just wanted to see what the other small scores were about.
i need to change this
hardcore brute force
Should work for any case and doesn't contain str2num or regexp :)
Fifth test cannot be true because 3.5^2 = 12.25
and no integer after squaring and adding will give such result
how can this be a leading solution?? Are all the cody problems like this?
I don't understand this solution. Can you explain it ?
Still without str2num or regexp
this would fail on assert(isequal(isTherePythagoreanTriple(1,4,7,9),false))
The benefit of a limited test suite.
Without using str2num or regexp
How to find the position of an element in a vector without using the find function
2477 Solvers
546 Solvers
276 Solvers
573 Solvers
369 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!