Cody

# Problem 3069. Pattern Recognition 2 - Known Unit Length, Various Array Length (including cell arrays)

Solution 1656505

Submitted on 23 Oct 2018
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
array = [1 2 3 1 2 3 1 2 3]; tf = 1; assert(isequal(pattern_recognition2(array),tf))

2   Pass
array = [1 2 2 1 2 2 1]; tf = 1; assert(isequal(pattern_recognition2(array),tf))

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

4   Pass
array = [1 10 100 1 10 100 1 10 100 1 10 100 1 10]; tf = 1; assert(isequal(pattern_recognition2(array),tf))

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test5 (line 3) assert(isequal(pattern_recognition2(array),tf))

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test6 (line 3) assert(isequal(pattern_recognition2(array),tf))

7   Fail
array = 'abcabcabcabcabcabcab'; tf = 1; assert(isequal(pattern_recognition2(array),tf))

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test7 (line 3) assert(isequal(pattern_recognition2(array),tf))

8   Fail
array = {'c3po','r2','d2','c3po','r2','d2','c3po','r2','d2','c3po','r2'}; tf = 1; assert(isequal(pattern_recognition2(array),tf))

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test8 (line 3) assert(isequal(pattern_recognition2(array),tf))

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

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test10 (line 3) assert(isequal(pattern_recognition2(array),tf))

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test11 (line 3) assert(isequal(pattern_recognition2(array),tf))

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

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test13 (line 3) assert(isequal(pattern_recognition2(array),tf))

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

Error using interp1>reshapeValuesV (line 439) Values V must be of type double or single. Error in interp1 (line 88) [V,orig_size_v] = reshapeValuesV(varargin{1}); Error in pattern_recognition2 (line 2) isequal(interp1(repmat(array(1:3), 1, ceil(length(array)/3)), 1:length(array)), array); Error in Test14 (line 3) assert(isequal(pattern_recognition2(array),tf))

15   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 2 3 1 2 3]; tf = 0; case 4 array = [1 2 2 1 2 2 1]; tf = 1; end assert(isequal(pattern_recognition2(array),tf))

16   Pass
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 100 10 1 10 100 1 10 100 1]; tf = 0; case 3 array = [1 2 2 1 2 2 1]; tf = 1; case 4 array = {'ab','cde','fg','ab','cde','fg','ab','cde','fg'}; tf = 1; end assert(isequal(pattern_recognition2(array),tf))