Pattern Recognition 3 - Variable Unit and Array Length (including cell arrays) - MATLAB Cody - MATLAB Central

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

Difficulty:Rate

You will be given various arrays, composed of numbers or strings, including cell arrays of strings. For this problem, the pattern unit length is variable, ranging from three to half the array length (the unit will be completely repeated at least once). Write a function to determine if the supplied array is a strict repeating pattern. The array will not necessarily have a length that is a multiple of the unit length.

For example, [1 2 3 4 5 1 2 3 4 5 1 2 3] would return true since the first block (1:5) is strictly repeated through the remainder of the array (including the last [1 2 3]). On the other hand, 'abcabcabcabcabcabea' would return false, since the last complete block is 'abe' rather than 'abc', as indicated by the first block.

This problem is a follow-on to Problem 3068 and Problem 3069.

Solution Stats

48.25% Correct | 51.75% Incorrect
Last Solution submitted on Mar 23, 2025

Problem Comments

Solution Comments

Show comments
Who Deserves Your Praise? Discover the New Contribution Widget!
...
We are excited to announce another update to our Discussions area: the...

Problem Recent Solvers48

Suggested Problems

More from this Author139

Community Treasure Hunt

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

Start Hunting!
Go to top of page