Cody

# Problem 51. Find the two most distant points

Solution 1538585

Submitted on 24 May 2018 by Nicholas Radziul
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))

xi = [] x = [] maxi = [] b = 4 2 f = [] x = 0 x = 0 1 x = 0 1 8 x = 0 1 8 1 xi = 8 H = 8 J = 1 x = 1 1 8 1 x = 1 0 8 1 x = 1 0 5 1 x = 1 0 5 2 xi = 8 5 H = 8 J = 1 x = 8 0 5 2 x = 8 5 5 2 x = 8 5 0 2 x = 8 5 0 5 xi = 8 5 8 H = 8 J = 1 x = 1 5 0 5 x = 1 2 0 5 x = 1 2 5 5 x = 1 2 5 0 xi = 8 5 8 5 H = 8 J = 1 f = 0 x = 0 2 5 0 x = 0 1 5 0 x = 0 1 8 0 x = 0 1 8 1 xi = 8 5 8 5 H = 8 J = 1 x = 1 1 8 1 x = 1 0 8 1 x = 1 0 5 1 x = 1 0 5 2 xi = 8 5 8 5 H = 8 J = 1 x = 8 0 5 2 x = 8 5 5 2 x = 8 5 0 2 x = 8 5 0 5 xi = 8 5 8 5 H = 8 J = 1 x = 1 5 0 5 x = 1 2 0 5 x = 1 2 5 5 x = 1 2 5 0 xi = 8 5 8 5 H = 8 J = 1 f = 0 1 x = 0 2 5 0 x = 0 1 5 0 x = 0 1 8 0 x = 0 1 8 1 xi = 8 5 8 5 H = 8 J = 1 x = 1 1 8 1 x = 1 0 8 1 x = 1 0 5 1 x = 1 0 5 2 xi = 8 5 8 5 H = 8 J = 1 x = 8 0 5 2 x = 8 5 5 2 x = 8 5 0 2 x = 8 5 0 5 xi = 8 5 8 5 H = 8 J = 1 x = 1 5 0 5 x = 1 2 0 5 x = 1 2 5 5 x = 1 2 5 0 xi = 8 5 8 5 H = 8 J = 1 f = 0 1 8 x = 0 2 5 0 x = 0 1 5 0 x = 0 1 8 0 x = 0 1 8 1 xi = 8 5 8 5 H = 8 J = 1 x = 1 1 8 1 x = 1 0 8 1 x = 1 0 5 1 x = 1 0 5 2 xi = 8 5 8 5 H = 8 J = 1 x = 8 0 5 2 x = 8 5 5 2 x = 8 5 0 2 x = 8 5 0 5 xi = 8 5 8 5 H = 8 J = 1 x = 1 5 0 5 x = 1 2 0 5 x = 1 2 5 5 x = 1 2 5 0 xi = 8 5 8 5 H = 8 J = 1 f = 0 1 8 1 M = 8 I = 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))

xi = [] x = [] maxi = [] b = 4 2 f = [] x = 0 x = 0 1 x = 0 1 8 x = 0 1 8 100 xi = 100 H = 100 J = 1 x = 1 1 8 100 x = 1 0 8 100 x = 1 0 5 100 x = 1 0 5 101 xi = 100 101 H = 101 J = 2 x = 8 0 5 101 x = 8 5 5 101 x = 8 5 0 101 x = 8 5 0 68 xi = 100 101 68 H = 101 J = 2 x = 100 5 0 68 x = 100 101 0 68 x = 100 101 68 68 x = 100 101 68 0 xi = 100 101 68 101 H = 101 J = 2 f = 1 x = 0 101 68 0 x = 0 1 68 0 x = 0 1 8 0 x = 0 1 8 100 xi = 100 101 68 101 H = 101 J = 2 x = 1 1 8 100 x = 1 0 8 100 x = 1 0 5 100 x = 1 0 5 101 xi = 100 101 68 101 H = 101 J = 2 x = 8 0 5 101 x = 8 5 5 101 x = 8 5 0 101 x = 8 5 0 68 xi = 100 101 68 101 H = 101 J = 2 x = 100 5 0 68 x = 100 101 0 68 x = 100 101 68 68 x = 100 101 68 0 xi = 100 101 68 101 H = 101 J = 2 f = 1 0 x = 0 101 68 0 x = 0 1 68 0 x = 0 1 8 0 x = 0 1 8 100 xi = 100 101 68 101 H = 101 J = 2 x = 1 1 8 100 x = 1 0 8 100 x = 1 0 5 100 x = 1 0 5 101 xi = 100 101 68 101 H = 101 J = 2 x = 8 0 5 101 x = 8 5 5 101 x = 8 5 0 101 x = 8 5 0 68 xi = 100 101 68 101 H = 101 J = 2 x = 100 5 0 68 x = 100 101 0 68 x = 100 101 68 68 x = 100 101 68 0 xi = 100 101 68 101 H = 101 J = 2 f = 1 0 5 x = 0 101 68 0 x = 0 1 68 0 x = 0 1 8 0 x = 0 1 8 100 xi = 100 101 68 101 H = 101 J = 2 x = 1 1 8 100 x = 1 0 8 100 x = 1 0 5 100 x = 1 0 5 101 xi = 100 101 68 101 H = 101 J = 2 x = 8 0 5 101 x = 8 5 5 101 x = 8 5 0 101 x = 8 5 0 68 xi = 100 101 68 101 H = 101 J = 2 x = 100 5 0 68 x = 100 101 0 68 x = 100 101 68 68 x = 100 101 68 0 xi = 100 101 68 101 H = 101 J = 2 f = 1 0 5 101 M = 101 I = 4 ix = 2 4

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

xi = [] x = [] maxi = [] b = 2 2 f = [] x = 0 x = 0 2501 xi = 2501 H = 2501 J = 1 x = 2501 2501 x = 2501 0 xi = 2501 2501 H = 2501 J = 1 f = 0 x = 0 0 x = 0 2501 xi = 2501 2501 H = 2501 J = 1 x = 2501 2501 x = 2501 0 xi = 2501 2501 H = 2501 J = 1 f = 0 2501 M = 2501 I = 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))

xi = [] x = [] maxi = [] b = 6 2 f = [] x = 0 x = 0 41 x = 0 41 18 x = 0 41 18 50 x = 0 41 18 50 11250 x = 0 41 18 50 11250 1146050 xi = 1146050 H = 1146050 J = 1 x = 41 41 18 50 11250 1146050 x = 41 0 18 50 11250 1146050 x = 41 0 5 50 11250 1146050 x = 41 0 5 101 11250 1146050 x = 41 0 5 101 10601 1146050 x = 41 0 5 101 10601 1158001 xi = 1146050 1158001 H = 1158001 J = 2 x = 18 0 5 101 10601 1158001 x = 18 5 5 101 10601 1158001 x = 18 5 0 101 10601 1158001 x = 18 5 0 68 10601 1158001 x = 18 5 0 68 10728 1158001 x = 18 5 0 68 10728 1154408 xi = 1146050 1158001 1154408 H = 1158001 J = 2 x = 50 5 0 68 10728 1154408 x = 50 101 0 68 10728 1154408 x = 50 101 68 68 10728 1154408 x = 50 101 68 0 10728 1154408 x = 50 101 68 0 10100 1154408 x = 50 101 68 0 10100 1152100 xi = 1146050 1158001 1154408 1152100 H = 1158001 J = 2 x = 11250 101 68 0 10100 1152100 x = 11250 10601 68 0 10100 1152100 x = 11250 10601 10728 0 10100 1152100 x = 11250 10601 10728 10100 10100 1152100 x = 11250 10601 10728 10100 0 1152100 x = 11250 10601 10728 10100 0 1354400 xi = 1146050 1158001 1154408 1152100 1354400 H = 1354400 J = 5 x = 1146050 10601 10728 10100 0 1354400 x = 1146050 1158001 10728 10100 0 1354400 x = 1146050 1158001 1154408 10100 0 1354400 x = 1146050 1158001 1154408 1152100 0 1354400 x = 1146050 1158001 1154408 1152100 1354400 1354400 x = 1146050 1158001 1154408 1152100 1354400 0 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 f = 11250 x = 0 1158001 1154408 1152100 1354400 0 x = 0 41 1154408 1152100 1354400 0 x = 0 41 18 1152100 1354400 0 x = 0 41 18 50 1354400 0 x = 0 41 18 50 11250 0 x = 0 41 18 50 11250 1146050 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 41 41 18 50 11250 1146050 x = 41 0 18 50 11250 1146050 x = 41 0 5 50 11250 1146050 x = 41 0 5 101 11250 1146050 x = 41 0 5 101 10601 1146050 x = 41 0 5 101 10601 1158001 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 18 0 5 101 10601 1158001 x = 18 5 5 101 10601 1158001 x = 18 5 0 101 10601 1158001 x = 18 5 0 68 10601 1158001 x = 18 5 0 68 10728 1158001 x = 18 5 0 68 10728 1154408 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 50 5 0 68 10728 1154408 x = 50 101 0 68 10728 1154408 x = 50 101 68 68 10728 1154408 x = 50 101 68 0 10728 1154408 x = 50 101 68 0 10100 1154408 x = 50 101 68 0 10100 1152100 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 11250 101 68 0 10100 1152100 x = 11250 10601 68 0 10100 1152100 x = 11250 10601 10728 0 10100 1152100 x = 11250 10601 10728 10100 10100 1152100 x = 11250 10601 10728 10100 0 1152100 x = 11250 10601 10728 10100 0 1354400 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 1146050 10601 10728 10100 0 1354400 x = 1146050 1158001 10728 10100 0 1354400 x = 1146050 1158001 1154408 10100 0 1354400 x = 1146050 1158001 1154408 1152100 0 1354400 x = 1146050 1158001 1154408 1152100 1354400 1354400 x = 1146050 1158001 1154408 1152100 1354400 0 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 f = 11250 10601 x = 0 1158001 1154408 1152100 1354400 0 x = 0 41 1154408 1152100 1354400 0 x = 0 41 18 1152100 1354400 0 x = 0 41 18 50 1354400 0 x = 0 41 18 50 11250 0 x = 0 41 18 50 11250 1146050 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 41 41 18 50 11250 1146050 x = 41 0 18 50 11250 1146050 x = 41 0 5 50 11250 1146050 x = 41 0 5 101 11250 1146050 x = 41 0 5 101 10601 1146050 x = 41 0 5 101 10601 1158001 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 18 0 5 101 10601 1158001 x = 18 5 5 101 10601 1158001 x = 18 5 0 101 10601 1158001 x = 18 5 0 68 10601 1158001 x = 18 5 0 68 10728 1158001 x = 18 5 0 68 10728 1154408 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 50 5 0 68 10728 1154408 x = 50 101 0 68 10728 1154408 x = 50 101 68 68 10728 1154408 x = 50 101 68 0 10728 1154408 x = 50 101 68 0 10100 1154408 x = 50 101 68 0 10100 1152100 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 11250 101 68 0 10100 1152100 x = 11250 10601 68 0 10100 1152100 x = 11250 10601 10728 0 10100 1152100 x = 11250 10601 10728 10100 10100 1152100 x = 11250 10601 10728 10100 0 1152100 x = 11250 10601 10728 10100 0 1354400 xi = 1146050 1158001 1154408 1152100 1354400 1354400 H = 1354400 J = 5 x = 1146050 10601 10728 10100 0 1354400 x = 1146050 1158001 10728 10100 0 1354400 x = ...

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!