Cody

# Problem 2735. Binary Neighbourhood

Solution 2783500

Submitted on 4 Aug 2020
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   Fail
x = 1; y_correct = 2; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test1 (line 3) assert(isequal(binary_neighbour(x),y_correct))

2   Fail
x = 2; y_correct = 1; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test2 (line 3) assert(isequal(binary_neighbour(x),y_correct))

3   Fail
x = 5; y_correct = 6; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test3 (line 3) assert(isequal(binary_neighbour(x),y_correct))

4   Fail
x = 3; y_correct = 5; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test4 (line 3) assert(isequal(binary_neighbour(x),y_correct))

5   Fail
x = 4; y_correct = 2; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test5 (line 3) assert(isequal(binary_neighbour(x),y_correct))

6   Fail
x = 16; y_correct = 8; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test6 (line 3) assert(isequal(binary_neighbour(x),y_correct))

7   Fail
x = 17; y_correct = 18; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test7 (line 3) assert(isequal(binary_neighbour(x),y_correct))

8   Fail
x = 11; y_correct = 13; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test8 (line 3) assert(isequal(binary_neighbour(x),y_correct))

9   Fail
x = 15; y_correct = 23; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test9 (line 3) assert(isequal(binary_neighbour(x),y_correct))

10   Fail
x = 92; y_correct = 90; assert(isequal(binary_neighbour(x),y_correct))

Undefined function 'de2bi' for input arguments of type 'double'. Error in binary_neighbour (line 2) w = sum(de2bi(x)); Error in Test10 (line 3) assert(isequal(binary_neighbour(x),y_correct))

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!