Cody

Problem 3070. Pattern Recognition 3 - Variable Unit and Array Length (including cell arrays)

Solution 2166884

Submitted on 20 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
array = [1 2 3 4 5 1 2 3 4 5 1 2 3]; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 1 2 3 4 array = 5 1 2 3 4 5 1 2 3 t = 5 1 2 3 array = 4 5 1 2 3

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test1 (line 3) assert(isequal(pattern_recognition3(array),tf))

2   Fail
array = [1 2 2 1 2 1 2 2 1 2 1 2]; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 1 2 2 1 array = 2 1 2 2 1 2 1 2 t = 2 1 2 2 array = 1 2 1 2

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test2 (line 3) assert(isequal(pattern_recognition3(array),tf))

3   Fail
array = [1 2 1 2 2 2 1 2]; tf = 0; assert(isequal(pattern_recognition3(array),tf))

t = 1 array = 2 1 2 2 2 1 2 t = 2 array = 1 2 2 2 1 2 t = 1 array = 2 2 2 1 2 t = 2 array = 2 2 1 2 t = 2 array = 2 1 2 t = 2 array = 1 2

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test3 (line 3) assert(isequal(pattern_recognition3(array),tf))

4   Fail
array = [0.1 1 10 100 1000 10000]; array = repmat(array,[1,5]); tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 1.0e+04 * 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000 0.0000 0.0001 0.0010 0.0100 0.1000 array = 1.0e+04 * Columns 1 through 17 1.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000 0.0000 0.0001 0.0010 0.0100 Columns 18 through 19 0.1000 1.0000 t = 1.0e+04 * 1.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000 0.0000 0.0001 0.0010 0.0100 array = 1.0e+04 * 0.1000 1.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test4 (line 4) assert(isequal(pattern_recognition3(array),tf))

5   Pass
array = {'c3po','r2','d2','c3po','d2','r2','c3po','r2','d2','c3po'}; tf = 0; assert(isequal(pattern_recognition3(array),tf))

tf = logical 0

6   Fail
array = 'hi ho hi ho hi ho hi'; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 'hi ho' array = ' hi ho hi ho hi' t = ' hi h' array = 'o hi ho hi' t = 'o hi ' array = 'ho hi'

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test6 (line 3) assert(isequal(pattern_recognition3(array),tf))

7   Fail
array = 'a':'z'; array = repmat(array,[1,5]); tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxy' array = 'zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' t = 'zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx' array = 'yzabcdefghijklmnopqrstuvwxyz'

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test7 (line 4) assert(isequal(pattern_recognition3(array),tf))

8   Fail
array = {'c3','po','r2','d2','c3','po','r2','d2','c3','po','r2','d2','c3','po','r2'}; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 1×3 cell array {'c3'} {'po'} {'r2'} array = 1×12 cell array {'d2'} {'c3'} {'po'} {'r2'} {'d2'} {'c3'} {'po'} {'r2'} {'d2'} {'c3'} {'po'} {'r2'} t = 1×3 cell array {'d2'} {'c3'} {'po'} array = 1×9 cell array {'r2'} {'d2'} {'c3'} {'po'} {'r2'} {'d2'} {'c3'} {'po'} {'r2'} t = 1×3 cell array {'r2'} {'d2'} {'c3'} array = 1×6 cell array {'po'} {'r2'} {'d2'} {'c3'} {'po'} {'r2'} t = 1×3 cell array {'po'} {'r2'} {'d2'} array = 1×3 cell array {'c3'} {'po'} {'r2'}

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test8 (line 3) assert(isequal(pattern_recognition3(array),tf))

9   Pass
array = [1 2 3 3 2 3 1 2 3 1]; tf = 0; assert(isequal(pattern_recognition3(array),tf))

tf = logical 0

10   Pass
array = {'ab','cde','fg','ab','cbe','fg','ab','edc','fg'}; tf = 0; assert(isequal(pattern_recognition3(array),tf))

tf = logical 0

11   Fail
array = 'abcabcabcabcabcabea'; tf = 0; assert(isequal(pattern_recognition3(array),tf))

t = 'abcab' array = 'cabcabcabcabea' t = 'cabca' array = 'bcabcabea' t = 'bcabc' array = 'abea'

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test11 (line 3) assert(isequal(pattern_recognition3(array),tf))

12   Pass
array = [1 10 100 1 100 10 1 10 100 1 10 100]; tf = 0; assert(isequal(pattern_recognition3(array),tf))

tf = logical 0

13   Fail
array = 'hi hi him'; tf = 0; assert(isequal(pattern_recognition3(array),tf))

t = 'hi' array = ' hi him' t = ' h' array = 'i him' t = 'i ' array = 'him'

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test13 (line 3) assert(isequal(pattern_recognition3(array),tf))

14   Fail
array = {'ab','cde','fg','ab','cde','fg','ab','cde','fg'}; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = 1×2 cell array {'ab'} {'cde'} array = 1×7 cell array {'fg'} {'ab'} {'cde'} {'fg'} {'ab'} {'cde'} {'fg'} t = 1×2 cell array {'fg'} {'ab'} array = 1×5 cell array {'cde'} {'fg'} {'ab'} {'cde'} {'fg'} t = 1×2 cell array {'cde'} {'fg'} array = 1×3 cell array {'ab'} {'cde'} {'fg'}

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test14 (line 3) assert(isequal(pattern_recognition3(array),tf))

15   Fail
array = [ones(1,40) zeros(1,20) ones(1,40) zeros(1,20) ones(1,40)]; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = Columns 1 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 58 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 59 0 array = Columns 1 through 29 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 58 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 88 through 101 1 1 1 1 1 1 1 1 1 1 1 1 1 1 t = Columns 1 through 29 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 58 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 59 0 array = Columns 1 through 29 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 30 through 42 1 1 1 1 1 1 1 1 1 1 1 1 1

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test15 (line 3) assert(isequal(pattern_recognition3(array),tf))

16   Fail
array = [-1:9 -1:4 -1:2 -1:9 -1:4 -1:2 -1:9 -1:4 -1:2 -1:9]; tf = 1; assert(isequal(pattern_recognition3(array),tf))

t = -1 0 1 2 3 4 5 6 7 8 9 -1 0 1 2 3 4 -1 0 1 array = Columns 1 through 29 2 -1 0 1 2 3 4 5 6 7 8 9 -1 0 1 2 3 4 -1 0 1 2 -1 0 1 2 3 4 5 Columns 30 through 54 6 7 8 9 -1 0 1 2 3 4 -1 0 1 2 -1 0 1 2 3 4 5 6 7 8 9 t = 2 -1 0 1 2 3 4 5 6 7 8 9 -1 0 1 2 3 4 -1 0 array = Columns 1 through 29 1 2 -1 0 1 2 3 4 5 6 7 8 9 -1 0 1 2 3 4 -1 0 1 2 -1 0 1 2 3 4 Columns 30 through 34 5 6 7 8 9 t = 1 2 -1 0 1 2 3 4 5 6 7 8 9 -1 0 1 2 3 4 -1 array = 0 1 2 -1 0 1 2 3 4 5 6 7 8 9

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test16 (line 3) assert(isequal(pattern_recognition3(array),tf))

17   Pass
ind = randi(4); switch ind case 1 array = {'c3po','r2','d2','c3po','r2','d2','c3po','r2','d2','c3po'}; tf = 1; case 2 array = 'hi hi him'; tf = 0; case 3 array = [1 2 3 3 1 2 3 1 2 3]; tf = 0; case 4 array = [1 2 2 4 1 2 2 4 1]; tf = 1; end assert(isequal(pattern_recognition3(array),tf))

tf = logical 0

18   Fail
ind = randi(4); switch ind case 1 array = [1 2 3 3 2 3 1 2 3 1 2]; tf = 0; case 2 array = [1 10 100 1 10 1 10 100 1 10 100 1]; tf = 0; case 3 array = [1 2 2 4 5 1 2 2 4 5 1]; tf = 1; case 4 array = {'ab','cde','ab','cde','fg','ab','cde','ab','cde','fg','ab','cde','ab','cde','fg'}; tf = 1; end assert(isequal(pattern_recognition3(array),tf))

t = 1 10 100 1 array = 10 1 10 100 1 10 100 1 t = 10 1 10 100 array = 1 10 100 1

Output argument "tf" (and maybe others) not assigned during call to "pattern_recognition3". Error in Test18 (line 16) assert(isequal(pattern_recognition3(array),tf))