Cody

# Problem 51. Find the two most distant points

Solution 434921

Submitted on 24 Apr 2014 by robin
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
%% p = [0 0; 1 0; 2 2; 0 1]; ix_correct = [1 3]; assert(isequal(mostDistant(p),ix_correct))

p = 0.0000 + 0.0000i 1.0000 + 0.0000i 2.0000 + 2.0000i 0.0000 + 1.0000i p = 0.0000 + 0.0000i -1.0000 + 0.0000i -2.0000 - 2.0000i 0.0000 - 1.0000i 1.0000 + 0.0000i 0.0000 + 0.0000i -1.0000 - 2.0000i 1.0000 - 1.0000i 2.0000 + 2.0000i 1.0000 + 2.0000i 0.0000 + 0.0000i 2.0000 + 1.0000i 0.0000 + 1.0000i -1.0000 + 1.0000i -2.0000 - 1.0000i 0.0000 + 0.0000i ind = 3 x = 3 y = 1 ix = 1 3

2   Pass
%% p = [0 0; 1 0; 2 2; 0 10]; ix_correct = [2 4]; assert(isequal(mostDistant(p),ix_correct))

p = 0.0000 + 0.0000i 1.0000 + 0.0000i 2.0000 + 2.0000i 0.0000 +10.0000i p = 0.0000 + 0.0000i -1.0000 + 0.0000i -2.0000 - 2.0000i 0.0000 -10.0000i 1.0000 + 0.0000i 0.0000 + 0.0000i -1.0000 - 2.0000i 1.0000 -10.0000i 2.0000 + 2.0000i 1.0000 + 2.0000i 0.0000 + 0.0000i 2.0000 - 8.0000i 0.0000 +10.0000i -1.0000 +10.0000i -2.0000 + 8.0000i 0.0000 + 0.0000i ind = 8 x = 4 y = 2 ix = 2 4

3   Pass
%% p = [0 0; -1 50]; ix_correct = [1 2]; assert(isequal(mostDistant(p),ix_correct))

p = 0.0000 + 0.0000i -1.0000 +50.0000i p = 0.0000 + 0.0000i 1.0000 -50.0000i -1.0000 +50.0000i 0.0000 + 0.0000i ind = 2 x = 2 y = 1 ix = 1 2

4   Pass
%% p = [5 5; 1 0; 2 2; 0 10; -100 20; 1000 400]; ix_correct = [5 6]; assert(isequal(mostDistant(p),ix_correct))

p = 1.0e+03 * 0.0050 + 0.0050i 0.0010 + 0.0000i 0.0020 + 0.0020i 0.0000 + 0.0100i -0.1000 + 0.0200i 1.0000 + 0.4000i p = 1.0e+03 * Columns 1 through 5 0.0000 + 0.0000i 0.0040 + 0.0050i 0.0030 + 0.0030i 0.0050 - 0.0050i 0.1050 - 0.0150i -0.0040 - 0.0050i 0.0000 + 0.0000i -0.0010 - 0.0020i 0.0010 - 0.0100i 0.1010 - 0.0200i -0.0030 - 0.0030i 0.0010 + 0.0020i 0.0000 + 0.0000i 0.0020 - 0.0080i 0.1020 - 0.0180i -0.0050 + 0.0050i -0.0010 + 0.0100i -0.0020 + 0.0080i 0.0000 + 0.0000i 0.1000 - 0.0100i -0.1050 + 0.0150i -0.1010 + 0.0200i -0.1020 + 0.0180i -0.1000 + 0.0100i 0.0000 + 0.0000i 0.9950 + 0.3950i 0.9990 + 0.4000i 0.9980 + 0.3980i 1.0000 + 0.3900i 1.1000 + 0.3800i Column 6 -0.9950 - 0.3950i -0.9990 - 0.4000i -0.9980 - 0.3980i -1.0000 - 0.3900i -1.1000 - 0.3800i 0.0000 + 0.0000i ind = 30 x = 6 y = 5 ix = 5 6