Cody

Problem 960. Cell Source Index

Solution 1983618

Submitted on 20 Oct 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
C = {'abc' 'd' 'ef' 'ghij'}; iC = [1 1 1 2 3 3 4 4 4 4]; assert(isequal(cellSourceIndex(C),iC))

s = [] iC = 1 1 1 iC = 1 1 1 2 iC = 1 1 1 2 3 3 iC = 1 1 1 2 3 3 4 4 4 4

2   Pass
C = {[1 2 3] [] 1 [] 2}; iC = [1 1 1 3 5]; assert(isequal(cellSourceIndex(C),iC))

s = [] iC = 1 1 1 iC = 1 1 1 iC = 1 1 1 3 iC = 1 1 1 3 iC = 1 1 1 3 5

3   Pass
assert(isequal(cellSourceIndex(num2cell(ones(3))),1:9))

s = [] iC = 1 iC = 1 2 iC = 1 2 3 iC = 1 2 3 4 iC = 1 2 3 4 5 iC = 1 2 3 4 5 6 iC = 1 2 3 4 5 6 7 iC = 1 2 3 4 5 6 7 8 iC = 1 2 3 4 5 6 7 8 9

4   Pass
assert(isequal(cellSourceIndex({[] [] [] 1}),4))

s = [] iC = 1×0 empty double row vector iC = 1×0 empty double row vector iC = 1×0 empty double row vector iC = 4

5   Pass
assert(isempty(cellSourceIndex({})))

s = []

6   Pass
C = {struct('a',{1 2},'b',[]),struct('c',{1 2}),struct('d',{5 6 7 8})}; iC = [1 1 2 2 3 3 3 3]; assert(isequal(cellSourceIndex(C),iC))

s = [] iC = 1 1 iC = 1 1 2 2 iC = 1 1 2 2 3 3 3 3