Cody

# Problem 362. Find matching string from a list of strings

Solution 2161592

Submitted on 16 Mar 2020
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
inStr = 'ball'; strList = {'ball', 'bell', 'barn'}; assert(isequal(findMatch(inStr, strList), 'ball'));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test1 (line 3) assert(isequal(findMatch(inStr, strList), 'ball'));

2   Fail
inStr = 'auG'; strList = {'May', 'June', 'July', 'August', 'September'}; assert(isequal(findMatch(inStr, strList), 'August'));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test2 (line 3) assert(isequal(findMatch(inStr, strList), 'August'));

3   Fail
inStr = 'Ju'; strList = {'May', 'June', 'July', 'August', 'September'}; assert(isequal(findMatch(inStr, strList), ''));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test3 (line 3) assert(isequal(findMatch(inStr, strList), ''));

4   Fail
inStr = 'fontn'; strList = {'FontName', 'FontUnits', 'FontSize', 'FontWeight'}; assert(isequal(findMatch(inStr, strList), 'FontName'));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test4 (line 3) assert(isequal(findMatch(inStr, strList), 'FontName'));

5   Fail
inStr = 'weight'; strList = {'FontName', 'FontUnits', 'FontSize', 'FontWeight'}; assert(isequal(findMatch(inStr, strList), 'FontWeight'));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test5 (line 3) assert(isequal(findMatch(inStr, strList), 'FontWeight'));

6   Fail
inStr = 'ball'; strList = {'baseball', 'balloon', 'ball'}; assert(isequal(findMatch(inStr, strList), 'ball'));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test6 (line 3) assert(isequal(findMatch(inStr, strList), 'ball'));

7   Fail
inStr = 'bal'; strList = {'baseball', 'balloon', 'ball'}; assert(isequal(findMatch(inStr, strList), ''));

Unable to perform assignment with 0 elements on the right-hand side. Error in findMatch (line 8) outstring = list{Index}; Error in Test7 (line 3) assert(isequal(findMatch(inStr, strList), ''));

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!