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))
word_table =
1×5 cell array
{'four'} {'one'} {'three'} {'two'} {'zero'}
str_index_list =
0×0 empty cell array
separado =
3×1 cell array
{'one' }
{'two' }
{'three'}
indices =
[]
indices =
2
indices =
2 4
indices =
2 4 3
str_index_list =
1×1 cell array
{1×3 double}
str_index_list =
1×1 cell array
{1×3 double}
separado =
4×1 cell array
{'two' }
{'one' }
{'four'}
{'zero'}
indices =
[]
indices =
4
indices =
4 2
indices =
4 2 1
indices =
4 2 1 5
str_index_list =
1×2 cell array
{1×3 double} {1×4 double}
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))
word_table =
1×3 cell array
{'one'} {'three'} {'two'}
str_index_list =
0×0 empty cell array
separado =
3×1 cell array
{'one' }
{'two' }
{'three'}
indices =
[]
indices =
1
indices =
1 3
indices =
1 3 2
str_index_list =
1×1 cell array
{1×3 double}
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))
word_table =
1×18 cell array
Columns 1 through 13
{'and'} {'at'} {'beef'} {'computer'} {'had'} {'home'} {'little'} {'market'} {'one'} {'piggy'} {'roast'} {'science'} {'stayed'}
Columns 14 through 18
{'studied'} {'this'} {'to'} {'university'} {'went'}
str_index_list =
0×0 empty cell array
separado =
6×1 cell array
{'this' }
{'little'}
{'piggy' }
{'went' }
{'to' }
{'market'}
indices =
[]
indices =
15
indices =
15 7
indices =
15 7 10
indices =
15 7 10 18
indices =
15 7 10 18 16
indices =
15 7 10 18 16 8
str_index_list =
1×1 cell array
{1×6 double}
str_index_list =
1×1 cell array
{1×6 double}
separado =
6×1 cell array
{'this' }
{'little'}
{'piggy' }
{'had' }
{'roast' }
{'beef' }
indices =
[]
indices =
15
indices =
15 7
indices =
15 7 10
indices =
15 7 10 5
indices =
15 7 10 5 11
indices =
15 7 10 5 11 3
str_index_list =
1×2 cell array
{1×6 double} {1×6 double}
str_index_list =
1×2 cell array
{1×6 double} {1×6 double}
separado =
6×1 cell array
{'and' }
{'this' }
{'little'}
{'piggy' }
{'stayed'}
{'home' }
indices =
[]
indices =
1
indices =
1 15
indices =
1 15 7
indices =
1 15 7 10
indices =
1 15 7 10 13
indices =
1 15 7 10 13 6
str_index_list =
1×3 cell array
{1×6 double} {1×6 double} {1×6 double}
str_index_list =
1×3 cell array
{1×6 double} {1×6 double} {1×6 double}
separado =
9×1 cell array
{'and' }
{'this' }
{'one' }
{'studied' }
{'computer' }
{'science' }
{'at' }
{'piggy' }
{'university'}
indices =
[]
indices =
1
indices =
1 15
indices =
1 15 9
indices =
1 15 9 14
indices =
1 15 9 14 4
indices =
1 15 9 14 4 12
indices =
1 15 9 14 4 12 2
indices =
1 15 9 14 4 12 2 10
indices =
1 15 9 14 4 12 2 10 17
str_index_list =
1×4 cell array
{1×6 double} {1×6 double} {1×6 double} {1×9 double}
str_index_list =
1×4 cell array
{1×6 double} {1×6 double} {1×6 double} {1×9 double}
|
Project Euler: Problem 6, Natural numbers, squares and sums.
1018 Solvers
404 Solvers
530 Solvers
257 Solvers
2982 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!