Cody

Solution 147526

Submitted on 12 Oct 2012
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% a = [1, 5, 3, 0, 2, 7, 0, 8, 9, 1 0]; b = 8; assert(isequal(nearZero(a),b))

index = 4 7 11 index_plus = 5 8 12 index_moins = 3 6 10 index = 3 6 10 5 8 12 end_x = 9 end_index = 12 end_index1 = 6 index = 3 6 10 5 8 10 ans = 3 7 1 2 8 1 y = 8

2   Pass
%% a = [5 4 -1 0 -2 0 -5 8]; b = -1; assert(isequal(nearZero(a),b));

index = 4 6 index_plus = 5 7 index_moins = 3 5 index = 3 5 5 7 end_x = 8 end_index = 7 end_index1 = 4 ans = -1 -2 -2 -5 y = -1

3   Pass
%% a = [0 3 1 0 2 9]; b = 3; assert(isequal(nearZero(a),b));

mem = 3 x = 3 1 0 2 9 index = 3 index_plus = 4 index_moins = 2 index = 2 4 end_x = 9 end_index = 4 end_index1 = 2 ans = 1 2 var = 1 2 3 y = 3

4   Fail
%% a = [1 0 2 0 3]; b = 3; assert(isequal(nearZero(a),b));

Error: Assertion failed.

5   Pass
%% a = [0 -1]; b = -1; assert(isequal(nearZero(a),b));

mem = -1 x = -1 index = [] index_plus = [] index_moins = [] index = [] end_x = -1 end_index = [] end_index1 = [] ans = [] var = -1 y = -1

6   Pass
%% a = [0 -12 0 -7 0]; b = -7; assert(isequal(nearZero(a),b));

mem = -12 x = -12 0 -7 0 index = 2 4 index_plus = 3 5 index_moins = 1 3 index = 1 3 3 5 end_x = 0 end_index = 5 end_index1 = 4 index = 1 3 3 3 ans = -12 -7 -7 -7 var = -12 -7 -7 -7 -12 y = -7