Cody

# Problem 51. Find the two most distant points

Solution 1977497

Submitted on 15 Oct 2019 by Alvin LAU
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))

x(:,:,1) = 0 1 2 0 -1 0 1 -1 -2 -1 0 -2 0 1 2 0 x(:,:,2) = 0 0 2 1 0 0 2 1 -2 -2 0 -1 -1 -1 1 0 x = 0 0 0 0 1 0 0 0 8 5 0 0 1 2 5 0 a = 1 b = 3 ix = 1 3

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

x(:,:,1) = 0 1 2 0 -1 0 1 -1 -2 -1 0 -2 0 1 2 0 x(:,:,2) = 0 0 2 10 0 0 2 10 -2 -2 0 8 -10 -10 -8 0 x = 0 0 0 0 1 0 0 0 8 5 0 0 100 101 68 0 a = 2 b = 4 ix = 2 4

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

x(:,:,1) = 0 -1 1 0 x(:,:,2) = 0 50 -50 0 x = 0 0 2501 0 a = 1 b = 2 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))

x(:,:,1) = 0 -4 -3 -5 -105 995 4 0 1 -1 -101 999 3 -1 0 -2 -102 998 5 1 2 0 -100 1000 105 101 102 100 0 1100 -995 -999 -998 -1000 -1100 0 x(:,:,2) = 0 -5 -3 5 15 395 5 0 2 10 20 400 3 -2 0 8 18 398 -5 -10 -8 0 10 390 -15 -20 -18 -10 0 380 -395 -400 -398 -390 -380 0 x = 0 0 0 0 0 0 41 0 0 0 0 0 18 5 0 0 0 0 50 101 68 0 0 0 11250 10601 10728 10100 0 0 1146050 1158001 1154408 1152100 1354400 0 a = 5 b = 6 ix = 5 6