Cody

# Problem 29. Nearest Numbers

Solution 1025987

Submitted on 21 Oct 2016 by INFOZOU
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
A = [30 46 16 -46 35 44 18 26 25 -10]; correct = [8 9]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 8 ind1 = 2 ind2 = 6 ind1 = 2 3 ind2 = 6 7 ind1 = 2 3 ind2 = 6 7 ind1 = 2 3 ind2 = 6 7 ind1 = 2 3 ind2 = 6 7 ind1 = 2 3 ind2 = 6 7 ind1 = 8 ind2 = 9 ind1 = 8 ind2 = 9 ind1 = 8 ind2 = 9

2   Pass
A = [1555 -3288 2061 -4681 -2230 -4538 -4028 3235 1949 -1829]; correct = [3 9]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 9 ind1 = 1 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9 ind1 = 3 ind2 = 9

3   Pass
A = [-1 1 10 -10]; correct = [1 2]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 2 ind1 = 1 ind2 = 2 ind1 = 1 ind2 = 2 ind1 = 1 ind2 = 2

4   Pass
A = [0 1000 -2000 1001 0]; correct = [1 5]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 5 ind1 = 1 ind2 = 5 ind1 = 1 ind2 = 5 ind1 = 1 ind2 = 5 ind1 = 1 ind2 = 5

5   Pass
A = [1:1000 0.5]; correct = [1 1001]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ind1 = 1 ind2 = 1001 ...

6   Pass
% Area codes A = [847 217 508 312 212]; correct = [2 5]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 3 ind1 = 2 ind2 = 5 ind1 = 2 ind2 = 5 ind1 = 2 ind2 = 5 ind1 = 2 ind2 = 5

7   Pass
% Zip codes A = [60048 61802 01702 60601 10001]; correct = [1 4]; [i1 i2] = nearestNumbers(A); assert(isequal([i1 i2],correct))

ind1 = 1 ind2 = 4 ind1 = 1 ind2 = 4 ind1 = 1 ind2 = 4 ind1 = 1 ind2 = 4 ind1 = 1 ind2 = 4