Cody

# Problem 51. Find the two most distant points

Solution 1903746

Submitted on 18 Aug 2019 by Tetsuji Tsuda
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))

diff = [] ix1 = [] ix2 = [] ix1 = 1 ix2 = 2 diff = 1 ix1 = 1 1 ix2 = 2 3 diff = 1 4 ix1 = 1 1 1 ix2 = 2 3 4 diff = 1 4 1 ix1 = 1 1 1 2 ix2 = 2 3 4 3 diff = 1 4 1 3 ix1 = 1 1 1 2 2 ix2 = 2 3 4 3 4 diff = 1 4 1 3 2 ix1 = 1 1 1 2 2 3 ix2 = 2 3 4 3 4 4 diff = 1 4 1 3 2 3 ix1 = 1 1 1 2 2 3 ix2 = 2 3 4 3 4 4 diff = 1 4 1 3 2 3 T = 6×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 2 1 1 3 4 1 4 1 2 3 3 2 4 2 3 4 3 T = 6×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 3 4 2 3 3 3 4 3 2 4 2 1 2 1 1 4 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))

diff = [] ix1 = [] ix2 = [] ix1 = 1 ix2 = 2 diff = 1 ix1 = 1 1 ix2 = 2 3 diff = 1 4 ix1 = 1 1 1 ix2 = 2 3 4 diff = 1 4 10 ix1 = 1 1 1 2 ix2 = 2 3 4 3 diff = 1 4 10 3 ix1 = 1 1 1 2 2 ix2 = 2 3 4 3 4 diff = 1 4 10 3 11 ix1 = 1 1 1 2 2 3 ix2 = 2 3 4 3 4 4 diff = 1 4 10 3 11 10 ix1 = 1 1 1 2 2 3 ix2 = 2 3 4 3 4 4 diff = 1 4 10 3 11 10 T = 6×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 2 1 1 3 4 1 4 10 2 3 3 2 4 11 3 4 10 T = 6×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 2 4 11 1 4 10 3 4 10 1 3 4 2 3 3 1 2 1 ix = 2 4

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

diff = [] ix1 = [] ix2 = [] ix1 = 1 ix2 = 2 diff = 51 ix1 = 1 ix2 = 2 diff = 51 T = 1×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 2 51 T = 1×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 2 51 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))

diff = [] ix1 = [] ix2 = [] ix1 = 1 ix2 = 2 diff = 9 ix1 = 1 1 ix2 = 2 3 diff = 9 6 ix1 = 1 1 1 ix2 = 2 3 4 diff = 9 6 10 ix1 = 1 1 1 1 ix2 = 2 3 4 5 diff = 9 6 10 120 ix1 = 1 1 1 1 1 ix2 = 2 3 4 5 6 diff = 9 6 10 120 1390 ix1 = 1 1 1 1 1 2 ix2 = 2 3 4 5 6 3 diff = 9 6 10 120 1390 3 ix1 = 1 1 1 1 1 2 2 ix2 = 2 3 4 5 6 3 4 diff = 9 6 10 120 1390 3 11 ix1 = 1 1 1 1 1 2 2 2 ix2 = 2 3 4 5 6 3 4 5 diff = 9 6 10 120 1390 3 11 121 ix1 = 1 1 1 1 1 2 2 2 2 ix2 = 2 3 4 5 6 3 4 5 6 diff = 9 6 10 120 1390 3 11 121 1399 ix1 = 1 1 1 1 1 2 2 2 2 3 ix2 = 2 3 4 5 6 3 4 5 6 4 diff = 9 6 10 120 1390 3 11 121 1399 10 ix1 = 1 1 1 1 1 2 2 2 2 3 3 ix2 = 2 3 4 5 6 3 4 5 6 4 5 diff = 9 6 10 120 1390 3 11 121 1399 10 120 ix1 = 1 1 1 1 1 2 2 2 2 3 3 3 ix2 = 2 3 4 5 6 3 4 5 6 4 5 6 diff = 9 6 10 120 1390 3 11 121 1399 10 120 1396 ix1 = 1 1 1 1 1 2 2 2 2 3 3 3 4 ix2 = 2 3 4 5 6 3 4 5 6 4 5 6 5 diff = 9 6 10 120 1390 3 11 121 1399 10 120 1396 110 ix1 = 1 1 1 1 1 2 2 2 2 3 3 3 4 4 ix2 = 2 3 4 5 6 3 4 5 6 4 5 6 5 6 diff = 9 6 10 120 1390 3 11 121 1399 10 120 1396 110 1390 ix1 = 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5 ix2 = 2 3 4 5 6 3 4 5 6 4 5 6 5 6 6 diff = 9 6 10 120 1390 3 11 121 1399 10 120 1396 110 1390 1480 ix1 = 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5 ix2 = 2 3 4 5 6 3 4 5 6 4 5 6 5 6 6 diff = 9 6 10 120 1390 3 11 121 1399 10 120 1396 110 1390 1480 T = 15×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 1 2 9 1 3 6 1 4 10 1 5 120 1 6 1390 2 3 3 2 4 11 2 5 121 2 6 1399 3 4 10 3 5 120 3 6 1396 4 5 110 4 6 1390 5 6 1480 T = 15×3 table <strong>ix1</strong> <strong>ix2</strong> <strong>diff</strong> <strong>___</strong> <strong>___</strong> <strong>____</strong> 5 6 1480 2 6 1399 3 6 1396 1 6 1390 4 6 1390 2 5 121 1 5 120 3 5 120 4 5 110 2 4 11 1 4 10 3 4 10 1 2 9 1 3 6 2 3 3 ix = 5 6