Cody

Solution 1570585

Submitted on 28 Jun 2018 by Jean-Marie Sainthillier
  • Size: 15
  • This is the leading solution.
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
% This Test Suite can be updated if inappropriate 'hacks' are discovered % in any submitted solutions, so your submission's status may therefore change over time. assessFunctionAbsence({'regexp', 'regexpi'}, 'FileName','checkInput.m') RE = regexp(fileread('checkInput.m'), '\w+', 'match'); tabooWords = {'ans'}; testResult = cellfun( @(z) ismember(z, tabooWords), RE ); msg = ['Please do not do that in your code!' char([10 13]) ... 'Found: ' strjoin(RE(testResult)) '.' char([10 13]) ... 'Banned word.' char([10 13])]; assert(~any( testResult ), msg)

2   Pass
global z x = 3; y = 2; z = 1; assert( checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

3   Pass
global z x = 1; y = 2; z = 3; assert( checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

4   Pass
global z x = 3; y = 1; z = 2; assert( checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

5   Pass
global z z = 2; assert( checkInput(z) ) assert( ~checkInput(1) ) assert( ~checkInput(3) )

6   Pass
global z z = 1; assert( checkInput(z) ) assert( ~checkInput(2) ) assert( ~checkInput(3) )

7   Pass
global z z = 3; assert( checkInput(z) ) assert( ~checkInput(1) ) assert( ~checkInput(2) )

8   Pass
global x y z x = 3; y = 1; z = 2; assert( checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

9   Pass
global x y z x = 2; y = 1; z = 3; assert( checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

10   Pass
global x y z x = 2; z = 3; testX = @(x) checkInput(x); testZ = @(z) checkInput(z); assert( ~testX(x) ) assert( ~testZ(x) ) assert( testX(z) ) assert( testZ(z) )

11   Pass
global x y z x = 3; z = 2; testX = @(x) checkInput(x); testZ = @(z) checkInput(z); assert( ~testX(x) ) assert( ~testZ(x) ) assert( testX(z) ) assert( testZ(z) )

12   Pass
clear global x = 1; y = 2; z = 3; assert( ~checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )

13   Pass
clear global x = 3; y = 2; z = 1; assert( ~checkInput(z) ) assert( ~checkInput(x) ) assert( ~checkInput(y) )