Problem 722. Make a run-length companion vector
Solution Stats
Problem Comments
-
5 Comments
The first test case seems to be invalid answer. Please check it
Hi Wenwu: Could you be more specific about what you think the problem is?
See FileExchange's seqle . (disclaimer: I'm the author)
False exemple description
y=[];
for i = 1:length(delta)
test = max(delta(1:i));
maxsofar=max(delta(1:i-1));
test2=min(delta(1:i));
minsofar=min(delta(1:i-1));
if test == delta(i) && delta(i)~= maxsofar
y=[y,1];
elseif test2 == delta(i) && delta(i)~= minsofar
y=[y,-1];
else
y=[y,0];
end
end
this code despite its giving correct results it is rejected by the tests...
Solution Comments
-
1 Comment
wrong answer for test suite 1
-
1 Comment
the 1st test suite seems not right.
-
1 Comment
the sol of first test isn't correct
Problem Recent Solvers585
Suggested Problems
-
Find relatively common elements in matrix rows
1341 Solvers
-
960 Solvers
-
Implement simple rotation cypher
1012 Solvers
-
Create a two dimensional zero matrix
409 Solvers
-
Solve a System of Linear Equations
7133 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!