Cody

Solution 1650404

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.')

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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.' )

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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;

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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;

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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;

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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;

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); 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;

Undefined function 'in64' for input arguments of type 'double'. Error in negativeRabbits (line 3) y = in64(((phi.^n) - (-phi).^(-n))./(2*phi-1)); Error in Test9 (line 3) assert( isequal(negativeRabbits(n)+negativeRabbits(n+1), negativeRabbits(n+2)) , ['Failed at n =' num2str(n) '.'])