Cody

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

Solution 1900966

Submitted on 15 Aug 2019
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'));

k = 1 q = logical 1 k = 1 q = 1×2 logical array 0 0 k = 1 q = 1×3 logical array 1 1 0 k = 1

Output argument "outStr" (and maybe others) not assigned during call to "findMatch". 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'));

q = logical 0

Undefined function or variable 'k'. Error in findMatch (line 17) k 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), ''));

q = logical 0

Undefined function or variable 'k'. Error in findMatch (line 17) k 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'));

q = logical 0

Undefined function or variable 'k'. Error in findMatch (line 17) k 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'));

q = logical 0

Undefined function or variable 'k'. Error in findMatch (line 17) k 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'));

k = 0 q = logical 1 k = 0 k = 0 0 q = 1×2 logical array 0 1 k = 0 0 k = 0 0 1 q = 1×3 logical array 1 0 1 k = 0 0 1

Output argument "outStr" (and maybe others) not assigned during call to "findMatch". Error in Test6 (line 3) assert(isequal(findMatch(inStr, strList), 'ball'));

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

k = 0 q = logical 1 k = 0 k = 0 0 q = 1×2 logical array 0 1 k = 0 0 k = 0 0 0 q = 1×3 logical array 1 0 1 k = 0 0 0

Output argument "outStr" (and maybe others) not assigned during call to "findMatch". Error in Test7 (line 3) assert(isequal(findMatch(inStr, strList), ''));