Cody

Problem 3108. Don't Try, give up and return NaN.

Solution 600982

Submitted on 24 Mar 2015
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   Fail
A = 1:5; N = [-1 2 6]; values = [NaN 2 NaN]; assert(isequaln(giveup(A,N),values))

Error: Assertion failed.

2   Fail
%% A = 10:-2:2; N = 5:-1:1; y_correct = 2:2:10; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

3   Fail
%% A = [1 2 3 4 10]; N = 5; y_correct = 10; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

4   Fail
%% A = 10:-2:2; N = -1; y_correct = NaN; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

5   Fail
%% A = [4 5 6]; N = [6 2]; y_correct = [NaN 5]; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

6   Fail
%% A = 4:randi([20 30]) ; N = randi(length(A)+20,1,10); K = N+3 ; K(K>max(A)) = NaN; y_correct = K; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

7   Fail
%% A = [-23 4 56 0 44 11]; N = [7:-1.5:-2]; y_correct = [NaN NaN 0 NaN -23 NaN NaN]; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

8   Fail
%% A = magic(3); N = magic(4); y_correct = [ NaN 3 4 NaN 5 NaN NaN 7 2 6 9 NaN 1 NaN NaN 8]; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

9   Fail
%% A = magic(3); N = magic(4)-1; y_correct = [ NaN 8 3 NaN 1 NaN 2 6 7 9 5 NaN 4 NaN NaN NaN]; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.

10   Fail
%% A = magic(4); N = magic(3)-1; y_correct = [ 7 NaN 2 5 4 11 9 14 16]; assert(isequaln(giveup(A,N),y_correct))

Error: Assertion failed.