Problem 3068. Pattern Recognition 1 - Known Unit Length
Solution Stats
Problem Comments
Solution Comments
-
2 Comments
Not sure why this solution gets marked as incorrect. I haven't been able to stump it. Can you find something wrong?
function [tf] = pattern_recognition1(array)
L = length(array);
one=array(1:3:L); two=array(2:3:L); three=array(3:3:L);
check = ((length(one) + length(two) = length(three)) /length(one);
c1 = all(one == one(1)); c2 = all(two == two(1)); c3 = all(three == three(1));
if c1 ==1 && c2 == 1 && c3 == 1
if check == 3;
tf = 1;
else tf = 0;
end
else tf = 0;
end
Line 5, replace 2nd "=" with "==".
-
2 Comments
Will fail on 'ababab'
You might wanna check the question again, @GeeTwo
Problem Recent Solvers45
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
4985 Solvers
-
Similar Triangles - find the height of the tree
251 Solvers
-
232 Solvers
-
10350 Solvers
-
Pattern Recognition 2 - Known Unit Length, Various Array Length (including cell arrays)
38 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!