Cody

# Problem 2733. Evil Number

Solution 1709103

Submitted on 18 Jan 2019 by Valentin Noël-Youïnou
• Size: 7
• 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
x = 1; y_correct = false; assert(isequal(isevil(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint1 (line 3) In solutionTest (line 3)]

2   Pass
x = 3; y_correct = true; assert(isequal(isevil(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint2 (line 3) In solutionTest (line 5)]

3   Pass
x = [18, 20, 23, 24, 27, 45, 46, 48, 96, 99, 123,]; y_correct = true; assert(isequal(all(arrayfun(@isevil,x)),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)]

4   Pass
x = [14, 16, 19, 37, 38, 55, 56, 59, 62, 79, 82, 91, 93, 94, 97, 98, 117, 118, 121]; y_correct = false; assert(isequal(any(arrayfun(@isevil,x)),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)]

5   Pass
x = 2^randi([5 10])+1; y_correct = true; assert(isequal(isevil(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In isevil (line 2) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11)]

6   Pass
% more test cases may be introduced

7   Pass
% DISABLED % ________'FAIR'_SCORING_SYSTEM______________ % % This section scores for usage of ans % and strings, which are common methods % to reduce cody size of solution. % Here, strings are threated like vectors. % Please do not hack it, as this problem % is not mentioned to be a hacking problem. % try % disable: assert(false) % size_old = feval(@evalin,'caller','score'); % all_nodes = mtree('isevil.m','-file'); str_nodes = mtfind(all_nodes,'Kind','STRING'); eq_nodes = mtfind(all_nodes,'Kind','EQUALS'); print_nodes = mtfind(all_nodes,'Kind','PRINT'); expr_nodes = mtfind(all_nodes,'Kind','EXPR'); % size = count(all_nodes) ... +sum(str_nodes.nodesize-1) ... +2*(count(expr_nodes) ... +count(print_nodes) ... -count(eq_nodes)); % feval(@assignin,'caller','score',size); % fprintf('Size in standard cody scoring is %i.\n',size_old); fprintf('Here it is %i.\n',size); end % %_________RESULT_____________________________

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In ScoringEngineTestPoint7 (line 15) In solutionTest (line 15)]