You are given a list of strings, each being a list of words divided by spaces. Break the strings into words, then return a master word table of all the words and an indexed version of each string.
The master list should have no repeated entries and should be sorted in alphabetical order.
Example
If str_list = {'one two three','two one four zero'}
then
Notice that no words are repeated in word_table, and each string in the string_list can be regenerated by referencing into the word_table using the string_index_list.
Something is broken on the third test case. I think the blank line between the 2nd and 3rd line of text is what's messing it up.
I submitted a solution that works for the first two cases and outputs perfect result (including the index output) for the last case on my desktop.
Somebody at the Cody team should check their test cases.
There is a workaround for the broken 3rd test case:
Because of the empty line, the size of sl is 2x2 instead of 1x4. So to bring sl into proper shape, just do str_list = str_list(:)' at the beginning of your code. This will leave the input for the first two test cases unchanged.
Thank you Jan for the workaround for the third test case.
Test suite doesn't check whether str_index_list is correct or not. It's incomplete.
There seems to be no check on the word indexing part of the problem. I passed the test suite without indexing at all.
Pretty kooky final test...
There seems to be no check on the word indexing part of the problem. I passed the test suite without indexing at all.
s1 = {'this is',...
'a cruel',...
'joke'};
Cheating with empty index output
str1 = {'one'} {'two'} {'three'} {'four'}
str2 = {'one'} {'three'} {'two'} {'four'}
the third test case may be broken, I can find no difference between my output and the output listed, and on my matlab the assertion does not fail.
The test suite doesn't even test half of what the problem asks for,
This solution properly solves for the string_index_list output, though this is not checked in the test suite.
Obviously, the index list is not checked...
The test suite does not check the 2nd output argument. This solution is not correct.
I forgot to do the str_index_lst, but the evaluator still accepted this. This should really be rejected as a solution.
14230 Solvers
Get the area codes from a list of phone numbers
417 Solvers
Compute a dot product of two vectors x and y
646 Solvers
Arrange vector in ascending order
541 Solvers
244 Solvers