Cody

# Problem 1203. Reference Index Number

Solution 2800819

Submitted on 6 Aug 2020 by Cassidy Fialkiewicz
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 K = [] K = 3 K = 3 5 K = 3 5 4 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))

K = [] K = 1 K = 1 4 K = 1 4 7 K = 1 4 7 10 K = 1 4 7 10 13 K = 1 4 7 10 13 16 K = 1 4 7 10 13 16 19 K = 1 4 7 10 13 16 19 22 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 K = [] K = 3 K = 3 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'} K = [] what = 'b' huh = 'a' what = 'b' huh = 'b' K = 2 what = 'b' huh = 'c' what = 'b' huh = 'd' what = 'a' huh = 'a' K = 2 1 what = 'a' huh = 'b' what = 'a' huh = 'c' what = 'a' huh = 'd' what = 'd' huh = 'a' what = 'd' huh = 'b' what = 'd' huh = 'c' what = 'd' huh = 'd' 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'} K = [] what = 'one' huh = 'one' K = 1 what = 'one' huh = 'two' what = 'one' huh = 'three' what = 'one' huh = 'red' what = 'one' huh = 'yellow' what = 'one' huh = 'blue' what = 'one' huh = 'dog' what = 'one' huh = 'cat' what = 'one' huh = 'fish' what = 'fish' huh = 'one' what = 'fish' huh = 'two' what = 'fish' huh = 'three' what = 'fish' huh = 'red' what = 'fish' huh = 'yellow' what = 'fish' huh = 'blue' what = 'fish' huh = 'dog' what = 'fish' huh = 'cat' what = 'fish' huh = 'fish' K = 1 9 what = 'two' huh = 'one' what = 'two' huh = 'two' K = 1 9 2 what = 'two' huh = 'three' what = 'two' huh = 'red' what = 'two' huh = 'yellow' what = 'two' huh = 'blue' what = 'two' huh = 'dog' what = 'two' huh = 'cat' what = 'two' huh = 'fish' what = 'fish' huh = 'one' what = 'fish' huh = 'two' what = 'fish' huh = 'three' what = 'fish' huh = 'red' what = 'fish' huh = 'yellow' what = 'fish' huh = 'blue' what = 'fish' huh = 'dog' what = 'fish' huh = 'cat' what = 'fish' huh = 'fish' K = 1 9 2 9 what = 'red' huh = 'one' what = 'red' huh = 'two' what = 'red' huh = 'three' what = 'red' huh = 'red' K = 1 9 2 9 4 what = 'red' huh = 'yellow' what = 'red' huh = 'blue' what = 'red' huh = 'dog' what = 'red' huh = 'cat' what = 'red' huh = 'fish' what = 'fish' huh = 'one' what = 'fish' huh = 'two' what = 'fish' huh = 'three' what = 'fish' huh = 'red' what = 'fish' huh = 'yellow' what = 'fish' huh = 'blue' what = 'fish' huh = 'dog' what = 'fish' huh = 'cat' what = 'fish' huh = 'fish' K = 1 9 2 9 4 9 what = 'blue' huh = 'one' what = 'blue' huh = 'two' what = 'blue' huh = 'three' what = 'blue' huh = 'red' what = 'blue' huh = 'yellow' what = 'blue' huh = 'blue' K = 1 9 2 9 4 9 6 what = 'blue' huh = 'dog' what = 'blue' huh = 'cat' what = 'blue' huh = 'fish' what = 'fish' huh = 'one' what = 'fish' huh = 'two' what = 'fish' huh = 'three' what = 'fish' huh = 'red' what = 'fish' huh = 'yellow' what = 'fish' huh = 'blue' what = 'fish' huh = 'dog' what = 'fish' huh = 'cat' what = 'fish' huh = 'fish' K = 1 9 2 9 4 9 6 9