Cody

Solution 808062

Submitted on 16 Jan 2016 by Shishir Patel
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 = 1; assert(isequal(nthodious(x),y_correct))

no_of_ones = 0 tf = 1 y = 1

2   Pass
%% x = 2; y_correct = 2; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 1 y = 2

3   Pass
%% x = 3; y_correct = 4; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 0 y = 4

4   Pass
%% x = 9; y_correct = 16; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 0 y = 16

5   Pass
%% x = 17; y_correct = 32; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 0 y = 32

6   Pass
%% x = 33; y_correct = 64; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 0 y = 64

7   Pass
%% x = 65; y_correct = 128; assert(isequal(nthodious(x),y_correct))

no_of_ones = 1 tf = 0 y = 128

8   Pass
%% x = 3387; y_correct = 6772; assert(isequal(nthodious(x),y_correct))

no_of_ones = 7 tf = 0 y = 6772

9   Pass
%% x = 22; y_correct = 42; assert(isequal(nthodious(x),y_correct))

no_of_ones = 3 tf = 1 y = 42

10   Pass
%% x = 1e5; y_correct = 2e5-1; assert(isequal(nthodious(x),y_correct))

no_of_ones = 10 tf = 0 y = 199999

11   Pass
%% % more test cases may be introduced

12   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 assert(false) % size_old = feval(@evalin,'caller','score'); % all_nodes = mtree('nthodious.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_____________________________