Cody

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

Solution 2831934

Submitted on 14 Aug 2020 by Hy Doan
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
inStr = 'ball'; strList = {'ball', 'bell', 'barn'}; assert(isequal(findMatch(inStr, strList), 'ball'));

naw = 1 beep = logical 0 boop = 0×0 empty cell array buup = 1×3 logical array 1 0 0 outS = 1×1 cell array {'ball'} outStr = 'ball'

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

naw = 4 beep = logical 0 boop = 0×0 empty cell array buup = 1×5 logical array 0 0 0 0 0 outS = 1×1 cell array {'August'} outStr = 'August'

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

naw = 2 3 beep = logical 0 boop = 0×0 empty cell array buup = 1×5 logical array 0 0 0 0 0 outS = 0×0 empty char array outStr = 0×0 empty char array

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

naw = 1 beep = logical 0 boop = 0×0 empty cell array buup = 1×4 logical array 0 0 0 0 outS = 1×1 cell array {'FontName'} outStr = 'FontName'

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

naw = 4 beep = logical 0 boop = 0×0 empty cell array buup = 1×4 logical array 0 0 0 0 outS = 1×1 cell array {'FontWeight'} outStr = 'FontWeight'

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

naw = 1 2 3 beep = logical 0 boop = 0×0 empty cell array buup = 1×3 logical array 0 0 1 outS = 1×1 cell array {'ball'} outStr = 'ball'

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

naw = 1 2 3 beep = logical 0 boop = 0×0 empty cell array buup = 1×3 logical array 0 0 0 outS = 0×0 empty char array outStr = 0×0 empty char array

### Community Treasure Hunt

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

Start Hunting!