Cody

# Problem 2121. Find offset of given matrix element from first matrix element

Solution 2049894

Submitted on 7 Dec 2019
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   Fail
m=[11 2 34; 40 51 6; 87 8 109] element = 51; offset = 5; assert(isequal(FindOffset(m,element),offset));

m = 11 2 34 40 51 6 87 8 109 y = 5 y = 5

Unrecognized function or variable 'esmpty'. Error in FindOffset (line 4) if esmpty y==1 Error in Test1 (line 4) assert(isequal(FindOffset(m,element),offset));

2   Fail
m=reshape([1:10],5,2); element = 9; offset = 9; assert(isequal(FindOffset(m,element),offset));

y = 9 y = 9

Unrecognized function or variable 'esmpty'. Error in FindOffset (line 4) if esmpty y==1 Error in Test2 (line 4) assert(isequal(FindOffset(m,element),offset));

3   Fail
m=eye(7); element = 0; offset = 2; assert(isequal(FindOffset(m,element),offset));

y = 2 3 4 5 6 7 8 10 11 12 13 14 15 16 18 19 20 21 22 23 24 26 27 28 29 30 31 32 34 35 36 37 38 39 40 42 43 44 45 46 47 48 y = 2

Unrecognized function or variable 'esmpty'. Error in FindOffset (line 4) if esmpty y==1 Error in Test3 (line 4) assert(isequal(FindOffset(m,element),offset));

4   Fail
m=[10 20 30 40; 50 60 70 80;]; element = 56; offset = 0; assert(isequal(FindOffset(m,element),offset));

y = 0×1 empty double column vector y = 0×1 empty double column vector

Unrecognized function or variable 'esmpty'. Error in FindOffset (line 4) if esmpty y==1 Error in Test4 (line 4) assert(isequal(FindOffset(m,element),offset));