Cody

# Problem 2317. Distance of the centroids of the balls

Solution 1020639

Submitted on 18 Oct 2016 by Peng Liu
• Size: 25
• This is the leading solution.
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 = 23

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!