Cody

# Problem 51. Find the two most distant points

Solution 1955618

Submitted on 2 Oct 2019 by Le Manh Long Le Manh Long
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))

t = [] d = [] x = 1 t = 1 x = 2 d = 1 2 t = 1.0000 2.8284 x = 3 d = 1 2 1 3 t = 1.0000 2.8284 1.0000 x = 4 d = 1 2 1 3 1 4 t = 1.0000 2.8284 1.0000 2.2361 x = 5 d = 1 2 1 3 1 4 2 3 t = 1.0000 2.8284 1.0000 2.2361 1.4142 x = 6 d = 1 2 1 3 1 4 2 3 2 4 t = 1.0000 2.8284 1.0000 2.2361 1.4142 2.2361 x = 7 d = 1 2 1 3 1 4 2 3 2 4 3 4 b = 2.8284 k = 1×6 logical array 0 1 0 0 0 0 m = 2 ix = 1 3

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

t = [] d = [] x = 1 t = 1 x = 2 d = 1 2 t = 1.0000 2.8284 x = 3 d = 1 2 1 3 t = 1.0000 2.8284 10.0000 x = 4 d = 1 2 1 3 1 4 t = 1.0000 2.8284 10.0000 2.2361 x = 5 d = 1 2 1 3 1 4 2 3 t = 1.0000 2.8284 10.0000 2.2361 10.0499 x = 6 d = 1 2 1 3 1 4 2 3 2 4 t = 1.0000 2.8284 10.0000 2.2361 10.0499 8.2462 x = 7 d = 1 2 1 3 1 4 2 3 2 4 3 4 b = 10.0499 k = 1×6 logical array 0 0 0 0 1 0 m = 5 ix = 2 4

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

t = [] d = [] x = 1 t = 50.0100 x = 2 d = 1 2 b = 50.0100 k = logical 1 m = 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))

t = [] d = [] x = 1 t = 6.4031 x = 2 d = 1 2 t = 6.4031 4.2426 x = 3 d = 1 2 1 3 t = 6.4031 4.2426 7.0711 x = 4 d = 1 2 1 3 1 4 t = 6.4031 4.2426 7.0711 106.0660 x = 5 d = 1 2 1 3 1 4 1 5 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 x = 6 d = 1 2 1 3 1 4 1 5 1 6 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 x = 7 d = 1 2 1 3 1 4 1 5 1 6 2 3 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 x = 8 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 x = 9 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 x = 10 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 x = 11 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 0.1036 x = 12 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 0.1036 1.0744 x = 13 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 0.1036 1.0744 0.1005 x = 14 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 0.1036 1.0744 0.1005 1.0734 x = 15 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 4 6 t = 1.0e+03 * 0.0064 0.0042 0.0071 0.1061 1.0705 0.0022 0.0100 0.1030 1.0761 0.0082 0.1036 1.0744 0.1005 1.0734 1.1638 x = 16 d = 1 2 1 3 1 4 1 5 1 6 2 3 2 4 2 5 2 6 3 4 3 5 3 6 4 5 4 6 5 6 b = 1.1638e+03 k = 1×15 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 m = 15 ix = 5 6