Cody

Solution 1608366

Submitted on 13 Aug 2018 by goc3
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
A = eye(3); y_correct = (1-A)*sqrt(2); tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

D = 0 1.4142 1.4142 1.4142 0 1.4142 1.4142 1.4142 0

2   Pass
A = (1:4)'; y_correct = [ 0 1 2 3;... 1 0 1 2;... 2 1 0 1;... 3 2 1 0]; tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

D = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0

3   Pass
A = magic(3); y_correct = [0 6.48074069840786 9.79795897113271; ... 6.48074069840786 0 6.48074069840786; ... 9.79795897113271 6.48074069840786 0]; tol = 1000*eps; assert(norm(interDist(A)-y_correct) < tol)

D = 0 6.4807 9.7980 6.4807 0 6.4807 9.7980 6.4807 0

4   Pass
A = reshape((1:20).^2,4,5); tol = 1e-12; y_correct = [0 49.4469412603045 102.761860629321 160.015624237135; ... 49.4469412603045 0 53.3385414123783 110.634533487515; ... 102.761860629321 53.3385414123783 0 57.3149195236284; ... 160.015624237135 110.634533487515 57.3149195236284 0]; assert(norm(interDist(A)-y_correct) < tol)

D = 0 49.4469 102.7619 160.0156 49.4469 0 53.3385 110.6345 102.7619 53.3385 0 57.3149 160.0156 110.6345 57.3149 0