Cody

Solution 2030693

Submitted on 21 Nov 2019 at 15:37 by dilek bulut
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
sl = {'one two three','two one four zero'}; wtc = {'four','one','three','two','zero'}; silc = {[2 4 3],[4 2 1 5]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

slsplit = 7×1 cell array {'one' } {'two' } {'three'} {'two' } {'one' } {'four' } {'zero' } dunik = 5×1 cell array {'four' } {'one' } {'three'} {'two' } {'zero' } word_table = 1×5 cell array {'four'} {'one'} {'three'} {'two'} {'zero'} civ = [] kat = [] bak = 2 ind = 5×1 cell array {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 2 civ = 2 ind = 5×1 cell array {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} index = 4 civ = 2 4 ind = 5×1 cell array {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} index = 3 civ = 2 4 3 ind = 5×1 cell array {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} index = 4 civ = 2 4 3 4 ind = 5×1 cell array {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 2 civ = 2 4 3 4 2 ind = 5×1 cell array {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 1 civ = 2 4 3 4 2 1 ind = 5×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} index = 5 civ = 2 4 3 4 2 1 5 spl = 3×1 cell array {'one' } {'two' } {'three'} as = 3 kat = 3 spl = 4×1 cell array {'two' } {'one' } {'four'} {'zero'} as = 4 kat = 3 4 lu = [] lu = 2 4 3 str_index_list = 1×1 cell array {1×3 double} lu = 4 2 1 5 str_index_list = 1×2 cell array {1×3 double} {1×4 double}

2   Pass
sl = {'one two three'}; wtc = {'one','three','two'}; silc = {[1 3 2]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

slsplit = 3×1 cell array {'one' } {'two' } {'three'} dunik = 3×1 cell array {'one' } {'three'} {'two' } word_table = 1×3 cell array {'one'} {'three'} {'two'} civ = [] kat = [] bak = 1 ind = 3×1 cell array {[ 1]} {0×0 double} {0×0 double} index = 1 civ = 1 ind = 3×1 cell array {0×0 double} {0×0 double} {[ 1]} index = 3 civ = 1 3 ind = 3×1 cell array {0×0 double} {[ 1]} {0×0 double} index = 2 civ = 1 3 2 spl = 3×1 cell array {'one' } {'two' } {'three'} as = 3 kat = 3 lu = [] lu = 1 3 2 str_index_list = 1×1 cell array {1×3 double}

3   Pass
sl = {'this little piggy went to market', ... 'and this little piggy stayed home', ... 'this little piggy had roast beef', ... 'and this one studied computer science at piggy university'}; wtc = { ... 'and','at','beef','computer','had','home', ... 'little','market','one','piggy','roast','science', ... 'stayed','studied','this','to','university','went'}; silc = { ... [15 7 10 18 16 8], ... [1 15 7 10 13 6], ... [15 7 10 5 11 3], ... [ 1 15 9 14 4 12 2 10 17]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

slsplit = 27×1 cell array {'this' } {'little' } {'piggy' } {'went' } {'to' } {'market' } {'this' } {'little' } {'piggy' } {'had' } {'roast' } {'beef' } {'and' } {'this' } {'little' } {'piggy' } {'stayed' } {'home' } {'and' } {'this' } {'one' } {'studied' } {'computer' } {'science' } {'at' } {'piggy' } {'university'} dunik = 18×1 cell array {'and' } {'at' } {'beef' } {'computer' } {'had' } {'home' } {'little' } {'market' } {'one' } {'piggy' } {'roast' } {'science' } {'stayed' } {'studied' } {'this' } {'to' } {'university'} {'went' } word_table = 1×18 cell array Columns 1 through 14 {'and'} {'at'} {'beef'} {'computer'} {'had'} {'home'} {'little'} {'market'} {'one'} {'piggy'} {'roast'} {'science'} {'stayed'} {'studied'} Columns 15 through 18 {'this'} {'to'} {'university'} {'went'} civ = [] kat = [] bak = 4 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 15 civ = 15 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 7 civ = 15 7 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 10 civ = 15 7 10 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} index = 18 civ = 15 7 10 18 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} index = 16 civ = 15 7 10 18 16 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 8 civ = 15 7 10 18 16 8 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 15 civ = 15 7 10 18 16 8 15 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 7 civ = 15 7 10 18 16 8 15 7 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 10 civ = 15 7 10 18 16 8 15 7 10 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 5 civ = 15 7 10 18 16 8 15 7 10 5 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 11 civ = 15 7 10 18 16 8 15 7 10 5 11 ind = 18×1 cell array {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 3 civ = 15 7 10 18 16 8 15 7 10 5 11 3 ind = 18×1 cell array {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 1 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 15 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 7 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 10 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 10 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 13 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 10 13 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 6 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 10 13 6 ind = 18×1 cell array {[ 1]} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} index = 1 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 10 13 6 1 ind = 18×1 cell array {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[ 1]} {0×0 double} {0×0 double} {0×0 double} index = 15 civ = 15 7 10 18 16 8 15 7 10 5 11 3 1 15 7 10 13 6 1 15 ind = 18×1 cell arra...