Cody

Solution 1719586

Submitted on 2 Feb 2019 by Nikolaos Nikolaou
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
R = 9:-1:5 V = [7 5 6 5]; K = [3 5 4 5]; assert(isequal(refIndex(R,V),K))

R = 9 8 7 6 5 t = 3 K = 3 t = 5 K = 3 5 t = 4 K = 3 5 4 t = 5 K = 3 5 4 5

2   Pass
R = 1:10 V = []; K = []; assert(isequal(refIndex(R,V),K))

R = 1 2 3 4 5 6 7 8 9 10 K = []

3   Pass
R = unique(randn(5)); V = R(1:3:end)'; K = 1:3:numel(R); assert(isequal(refIndex(R,V),K))

t = 1 K = 1 t = 4 K = 1 4 t = 7 K = 1 4 7 t = 10 K = 1 4 7 10 t = 13 K = 1 4 7 10 13 t = 16 K = 1 4 7 10 13 16 t = 19 K = 1 4 7 10 13 16 19 t = 22 K = 1 4 7 10 13 16 19 22 t = 25 K = 1 4 7 10 13 16 19 22 25

4   Pass
R = -2:2 V = [0 0 0]; K = [3 3 3]; assert(isequal(refIndex(R,V),K))

R = -2 -1 0 1 2 t = 3 K = 3 t = 3 K = 3 3 t = 3 K = 3 3 3

5   Pass
R = {'a' 'b' 'c' 'd'} V = {'b' 'a' 'd'}; K = [2 1 4]; assert(isequal(refIndex(R,V),K))

R = 1×4 cell array {'a'} {'b'} {'c'} {'d'} t = 1×3 cell array {'b'} {'a'} {'d'} K1 = 2 1 4 sel = 1×3 cell array {0×0 double} {[1]} {0×0 double} K = 0 0 0 tra = 1×3 cell array {[1]} {0×0 double} {0×0 double} A = 1 K = 2 0 0 tra = 1×3 cell array {0×0 double} {[1]} {0×0 double} A = 2 K = 2 1 0 tra = 1×3 cell array {0×0 double} {0×0 double} {[1]} A = 3 K = 2 1 4

6   Pass
R = {'one' 'two' 'three' 'red' 'yellow' 'blue' 'dog' 'cat' 'fish'} V = {'one' 'fish' 'two' 'fish' 'red' 'fish' 'blue' 'fish'}; K = [1 9 2 9 4 9 6 9]; assert(isequal(refIndex(R,V),K))

R = 1×9 cell array {'one'} {'two'} {'three'} {'red'} {'yellow'} {'blue'} {'dog'} {'cat'} {'fish'} t = 1×5 cell array {'one'} {'fish'} {'two'} {'red'} {'blue'} K1 = 1 9 2 4 6 sel = 1×8 cell array {0×0 double} {[1]} {0×0 double} {[1]} {0×0 double} {[1]} {0×0 double} {[1]} K = 0 0 0 0 0 0 0 0 tra = 1×8 cell array {[1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} A = 1 K = 1 0 0 0 0 0 0 0 tra = 1×8 cell array {0×0 double} {[1]} {0×0 double} {[1]} {0×0 double} {[1]} {0×0 double} {[1]} A = 2 4 6 8 K = 1 9 0 9 0 9 0 9 tra = 1×8 cell array {0×0 double} {0×0 double} {[1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} A = 3 K = 1 9 2 9 0 9 0 9 tra = 1×8 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[1]} {0×0 double} {0×0 double} {0×0 double} A = 5 K = 1 9 2 9 4 9 0 9 tra = 1×8 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[1]} {0×0 double} A = 7 K = 1 9 2 9 4 9 6 9

Suggested Problems