input => errorsequence = [10 20 21 40]
output => truesequence = [19 20 21 22] , errorposition = [1 4]
Result: Test fail
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%% test 1
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 | Pass |
%%test 2
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
|
Replace NaNs with the number that appears to its left in the row.
1710 Solvers
Given an unsigned integer x, find the largest y by rearranging the bits in x
524 Solvers
All your base are belong to us
425 Solvers
138 Solvers
Determine the number of odd integers in a vector
320 Solvers