Cody

Solution 1619768

Submitted on 31 Aug 2018 by Srishti Saha
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))

arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 1 ans = logical 0

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

arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 3 ans = logical 1

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

arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 18 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 20 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 23 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 24 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 27 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 45 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 46 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 48 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 96 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 99 ans = logical 1 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 123 ans = logical 1

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

arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 14 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 16 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 19 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 37 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 38 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 55 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 56 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 59 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 62 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 79 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 82 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 91 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 93 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 94 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 97 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 98 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 117 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 118 ans = logical 0 arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 121 ans = logical 0

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

arr = Columns 1 through 29 0 3 5 6 9 10 12 15 17 18 20 23 24 27 29 30 33 34 36 39 40 43 45 46 48 51 53 54 57 Columns 30 through 58 58 60 63 65 66 68 71 72 75 77 78 80 83 85 86 89 90 92 95 96 99 101 102 105 106 108 111 113 114 Columns 59 through 65 116 119 120 123 125 126 129 n = 129 ans = logical 1

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_____________________________

Suggested Problems

More from this Author41