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))
t =
46
t =
16
t =
14
t =
5
t =
4
t =
2
t =
1
|
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))
t =
3235
t =
506
t =
394
t =
112
|
3 | Pass |
A = [-1 1 10 -10];
correct = [1 2];
[i1 i2] = nearestNumbers(A);
assert(isequal([i1 i2],correct))
t =
10
t =
2
|
4 | Pass |
A = [0 1000 -2000 1001 0];
correct = [1 5];
[i1 i2] = nearestNumbers(A);
assert(isequal([i1 i2],correct))
t =
1001
t =
1000
t =
0
|
5 | Pass |
A = [1:1000 0.5];
correct = [1 1001];
[i1 i2] = nearestNumbers(A);
assert(isequal([i1 i2],correct))
t =
1000
t =
1
t =
0.5000
|
6 | Pass |
% Area codes
A = [847 217 508 312 212];
correct = [2 5];
[i1 i2] = nearestNumbers(A);
assert(isequal([i1 i2],correct))
t =
847
t =
630
t =
339
t =
291
t =
95
t =
5
|
7 | Pass |
% Zip codes
A = [60048 61802 01702 60601 10001];
correct = [1 4];
[i1 i2] = nearestNumbers(A);
assert(isequal([i1 i2],correct))
t =
61802
t =
1754
t =
553
|
Find the sum of all the numbers of the input vector
31956 Solvers
261 Solvers
192 Solvers
Back to basics 3 - Temp Directory
328 Solvers
386 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!