Cody

# Problem 44628. The other half of the Fibonacci sequence

Solution 1650406

Submitted on 16 Oct 2018
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
% Banning these to discourage hard-coded answers and silly 'scoring cheats'. Sorry if it disrupts some legitimate usage. % Please don't try any other hacks or workarounds. assessFunctionAbsence({'str2num','str2double','regexp', 'regexpi'}, 'FileName','negativeRabbits.m'); FR = fileread('negativeRabbits.m'); msg = 'Don''t hard-code your ''solution''.'; assert( ~any( cellfun( @(z) contains(FR, z) , {'54800875592', '716768017756', '9845401187926'} ) ) , msg )

2   Pass
% I don't think it's very good style to be using "ans". RE = regexp(fileread('negativeRabbits.m'), '\w+', 'match'); tabooWords = {'ans'}; testResult = cellfun( @(z) ismember(z, tabooWords), RE ); msg = ['Please do not include the following banned strings in your code!' char([10 13]) ... strjoin(RE(testResult)) char([10 13])]; assert(~any( cellfun( @(z) ismember(z, tabooWords), RE ) ), msg)

3   Fail
% This is important. assert( isequal( class(negativeRabbits(0)) , 'int64' ) , 'Wrong data type.')

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test3 (line 2) assert( isequal( class(negativeRabbits(0)) , 'int64' ) , 'Wrong data type.')

4   Fail
% Test Suite shall ensure it only ever checks n < 3. assert( isequal(negativeRabbits(+2), 1) , 'Failed at n =+2.' ) assert( isequal(negativeRabbits(+1), 1) , 'Failed at n =+1.' ) assert( isequal(negativeRabbits( 0), 0) , 'Failed at n = 0.' ) assert( isequal(negativeRabbits(-1), 1) , 'Failed at n =-1.' )

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test4 (line 2) assert( isequal(negativeRabbits(+2), 1) , 'Failed at n =+2.' )

5   Fail
for n = 0 : -1 : -10 assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.']) end;

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test5 (line 2) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])

6   Fail
for n = -10 : -1 : -20 assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.']) end;

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test6 (line 2) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])

7   Fail
for n = -20 : -1 : -40 assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.']) end;

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test7 (line 2) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])

8   Fail
for n = -40 : -1 : -77 assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.']) end;

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test8 (line 2) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])

9   Fail
% This is difficult, but feasible within the parameters of the problem. for n = -77 : -1 : -92 assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.']) end;

Output argument "F" (and maybe others) not assigned during call to "negativeRabbits". Error in Test9 (line 3) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])