Cody

Problem 2317. Distance of the centroids of the balls

Solution 2133543

Submitted on 19 Feb 2020 by Piotr Lesniewski
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 1e3; l = 10; r = 0.5; p = [ repmat([.5:9.5]',l^2,1),... repmat(reshape(repmat([.5:9.5]',1,10)',l^2,1),l,1),... reshape(repmat([.5:9.5]',1,100)',l^3,1)]; A_test = zeros(l^3); for i1 = 1:l^3 for i2 = 1:l^3 A_test(i1, i2) = norm(p(i1,:)-p(i2,:)); end end assert(isequal(dist_ball(p),A_test))

2   Pass
n = randi(1e2) p = randi([-1e6,1e6],n,3); A_test = zeros(n); for i1 = 1:n for i2 = 1:n A_test(i1, i2) = norm(p(i1,:)-p(i2,:)); end end assert(isequal(dist_ball(p),A_test))

n = 86

3   Pass
assert( isempty(regexp(evalc('type dist_ball'),'(str|printf|eval|flip|dec2base|regexp)')) )