Test | Status | Code Input and Output |
---|---|---|
1 | Fail |
nterms = 10;
term0 = randi(10);
increment = (-1)^randi(2)*randi(10);
correctsequence = term0:increment:term0+(nterms-1)*increment;
for position = 1:nterms
errorsequence = correctsequence;
errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50);
[errorposition, truesequence] = find_error(errorsequence);
assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 1 at position %d', position);
end
|
2 | Fail |
nterms = 201;
term0 = randi(10);
increment = (-1)^randi(2)*randi(10);
correctsequence = term0:increment:term0+(nterms-1)*increment;
for position = 1:10:nterms
errorsequence = correctsequence;
errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50);
[errorposition, truesequence] = find_error(errorsequence);
assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 2 at position %d', position);
end
|
What is the next step in Conway's Life?
640 Solvers
Project Euler: Problem 8, Find largest product in a large string of numbers
315 Solvers
Change the sign of even index entries of the reversed vector
297 Solvers
Relative ratio of "1" in binary number
393 Solvers
Find the index of n in magic(n)
160 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!