Cody

Solution 1632736

Submitted on 24 Sep 2018 by Michael Jarboe
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
first = 'minimum'; second = 'maximum'; match = substrmatch( first, second ); assert( strcmp( match, 'imum' ) )

y = 0×0 empty char array x = 1 5 7 longest = 1 y = 'm' s = 'ma' x = [] s = 'x' x = [] s = 'i' x = 2 4 s = 'im' x = 4 longest = 2 y = 'im' s = 'imu' x = 4 longest = 3 y = 'imu' s = 'imum' x = 4 longest = 4 y = 'imum'

2   Pass
first = 'aabbcc'; second = 'abc'; match = substrmatch( first, second ); assert( strcmp( match, 'ab' ) || strcmp( match, 'bc' ) )

y = 0×0 empty char array x = 1 2 longest = 1 y = 'a' s = 'ab' x = 2 longest = 2 y = 'ab' s = 'abc' x = []

3   Pass
first = 'MATLAB'; second = 'LAPACK'; match = substrmatch( first, second ); assert( strcmp( match, 'LA' ) )

y = 0×0 empty char array x = 4 longest = 1 y = 'L' s = 'LA' x = 4 longest = 2 y = 'LA' s = 'LAP' x = [] s = 'A' x = 2 5 s = 'AC' x = [] s = 'K' x = []

4   Pass
first = 'abc'; second = 'def'; match = substrmatch( first, second ); assert( strcmp( match, '' ) )

y = 0×0 empty char array x = [] s = 'e' x = [] s = 'f' x = []

5   Pass
first = 'banana'; second = 'anagram'; match = substrmatch( first, second ); assert( strcmp( match, 'ana' ) )

y = 0×0 empty char array x = 2 4 6 longest = 1 y = 'a' s = 'an' x = 2 4 longest = 2 y = 'an' s = 'ana' x = 2 4 longest = 3 y = 'ana' s = 'anag' x = [] s = 'r' x = [] s = 'a' x = 2 4 6 s = 'am' x = []

6   Pass
first = 'string within a string'; second = 'within'; match = substrmatch( first, second ); assert( strcmp( match, 'within' ) )

y = 0×0 empty char array x = 8 longest = 1 y = 'w' s = 'wi' x = 8 longest = 2 y = 'wi' s = 'wit' x = 8 longest = 3 y = 'wit' s = 'with' x = 8 longest = 4 y = 'with' s = 'withi' x = 8 longest = 5 y = 'withi' s = 'within' x = 8 longest = 6 y = 'within'

7   Pass
first = 'yes and no'; second = 'ankles and noses'; match = substrmatch( first, second ); assert( strcmp( match, 'es and no' ) )

y = 0×0 empty char array x = 5 longest = 1 y = 'a' s = 'an' x = 5 longest = 2 y = 'an' s = 'ank' x = [] s = 'l' x = [] s = 'e' x = 2 s = 'es' x = 2 s = 'es ' x = 2 longest = 3 y = 'es ' s = 'es a' x = 2 longest = 4 y = 'es a' s = 'es an' x = 2 longest = 5 y = 'es an' s = 'es and' x = 2 longest = 6 y = 'es and' s = 'es and ' x = 2 longest = 7 y = 'es and ' s = 'es and n' x = 2 longest = 8 y = 'es and n' s = 'es and no' x = 2 longest = 9 y = 'es and no' s = 'es and nos' x = [] s = 'e' x = 2 s = 'es' x = 2

8   Pass
first = 'three apples'; second = 'one apple'; match = substrmatch( first, second ); assert( strcmp( match, 'e apple' ) )

y = 0×0 empty char array x = [] s = 'n' x = [] s = 'e' x = 4 5 11 longest = 1 y = 'e' s = 'e ' x = 5 longest = 2 y = 'e ' s = 'e a' x = 5 longest = 3 y = 'e a' s = 'e ap' x = 5 longest = 4 y = 'e ap' s = 'e app' x = 5 longest = 5 y = 'e app' s = 'e appl' x = 5 longest = 6 y = 'e appl' s = 'e apple' x = 5 longest = 7 y = 'e apple'

9   Pass
first = 'hello there'; second = 'jello that'; match = substrmatch( first, second ); assert( strcmp( match, 'ello th' ) )

y = 0×0 empty char array x = [] s = 'e' x = 2 9 11 longest = 1 y = 'e' s = 'el' x = 2 longest = 2 y = 'el' s = 'ell' x = 2 longest = 3 y = 'ell' s = 'ello' x = 2 longest = 4 y = 'ello' s = 'ello ' x = 2 longest = 5 y = 'ello ' s = 'ello t' x = 2 longest = 6 y = 'ello t' s = 'ello th' x = 2 longest = 7 y = 'ello th' s = 'ello tha' x = [] s = 't' x = 7

Suggested Problems

More from this Author5