This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
cd=randi(100);
gd=-randi(100);
linef=(cd-gd)*rand(randi([50,100]),2)+gd;
%
n=size(linef,1);
ldist=zeros(n);
for a=1:n
for b=1:n
if linef(a,1)>0&&linef(b,2)>0
ldist(b,a)=(linef(a,1)+linef(b,2)-cd).^2;
elseif linef(a,1)<0&&linef(b,2)<0
ldist(b,a)=(linef(a,1)+linef(b,2)-gd).^2;
else
ldist(b,a)=(abs(linef(a,1)-linef(b,2))-(cd-gd)).^2;
end
end
end
y_correct=ldist;
f_result=measure_dist(linef,cd,gd);
assert(all(abs(f_result(:)-y_correct(:))<0.1))
|
Find the longest sequence of 1's in a binary sequence.
3370 Solvers
277 Solvers
Test if two numbers have the same digits
187 Solvers
2316 Solvers
616 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!