Cody

# Problem 42672. longest sequence of nans

Solution 767398

Submitted on 26 Oct 2015 by Zikobrelli
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
%% x = [ 2 3 1 2 5 6; nan nan 5 nan 6 -9; 5 nan 8 nan 6 5; 8 nan 7 -5 5.8 5; nan 0 0 nan 5 7; nan 5 9 nan 7 nan; nan nan 10 0 nan 6; nan nan 0 1 nan 9]; y_correct = [ 4 3 0 2 2 1]; assert(isequal(longnan(x),y_correct));

y = 0 0 0 0 0 0 A = 0 0 1 0 0 1 1 1 1 0 y = 4 0 0 0 0 0 A = 0 0 1 1 1 0 0 1 1 0 y = 4 3 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 0 y = 4 3 0 0 0 0 A = 0 0 1 1 0 1 1 0 0 0 y = 4 3 0 2 0 0 A = 0 0 0 0 0 0 0 1 1 0 y = 4 3 0 2 2 0 A = 0 0 0 0 0 0 1 0 0 0 y = 4 3 0 2 2 1

2   Pass
%% x = eye(3); y_correct = [0 0 0]; assert(isequal(longnan(x),y_correct));

y = 0 0 0 A = 0 0 0 0 0 y = 0 0 0 A = 0 0 0 0 0 y = 0 0 0 A = 0 0 0 0 0 y = 0 0 0

3   Pass
%% x = eye(3); x(1,1) = nan; y_correct = [1 0 0]; assert(isequal(longnan(x),y_correct));

y = 0 0 0 A = 0 1 0 0 0 y = 1 0 0 A = 0 0 0 0 0 y = 1 0 0 A = 0 0 0 0 0 y = 1 0 0

4   Pass
%% x = [30 39 NaN 1 10 NaN 28 38 47 NaN 9 18 27 NaN 46 NaN NaN 17 NaN NaN 37 5 NaN NaN 25 NaN 36 NaN 13 15 NaN 33 NaN NaN NaN 21 NaN 32 41 43 3 NaN 22 31 NaN 49 2 NaN NaN]; y_correct = [0 2 5 0 3 1 4]; assert(isequal(longnan(x),y_correct));

y = 0 0 0 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 A = 0 0 0 1 1 0 1 0 0 y = 0 2 0 0 0 0 0 A = 0 1 1 1 1 1 0 1 0 y = 0 2 5 0 0 0 0 A = 0 0 0 0 0 0 0 0 0 y = 0 2 5 0 0 0 0 A = 0 0 0 1 1 1 0 0 0 y = 0 2 5 0 3 0 0 A = 0 1 0 1 0 1 0 1 0 y = 0 2 5 0 3 1 0 A = 0 0 1 0 1 1 1 1 0 y = 0 2 5 0 3 1 4

5   Pass
%% x = nan(10); y_correct = repmat(10,1,10); assert(isequal(longnan(x),y_correct));

y = 0 0 0 0 0 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 0 0 0 0 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 0 0 0 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 0 0 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 0 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 0 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 10 0 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 10 10 0 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 10 10 10 0 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 10 10 10 10 0 A = 0 1 1 1 1 1 1 1 1 1 1 0 y = 10 10 10 10 10 10 10 10 10 10