Cody

# Problem 44232. Relation between functions "dec2bin" & "dec2binvec"

Solution 1215833

Submitted on 19 Jun 2017
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
filetext = fileread('dec_2_binvec.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp() and its family are forbidden') assert(isempty(strfind(filetext, 'dec2binvec')),'dec2binvec() forbidden') assert(isempty(strfind(filetext, 'num2str')),'num2str() forbidden') assert(isempty(strfind(filetext, 'regexprep')),'regexprep() forbidden') assert(isempty(strfind(filetext, 'for')),'for() forbidden') assert(isempty(strfind(filetext, 'while')),'while() forbidden') assert(isempty(strfind(filetext, 'if')),'if() forbidden') assert(isempty(strfind(filetext, 'mrdivide')),'mrdivide() forbidden') assert(isempty(strfind(filetext, 'mldivide')),'mldivide() forbidden') assert(isempty(strfind(filetext, '\')),'\ forbidden') assert(isempty(strfind(filetext, '/')),'/ forbidden') assert(isempty(strfind(filetext, '^')),'^ forbidden') assert(isempty(strfind(filetext, 'rem')),'rem() forbidden') assert(isempty(strfind(filetext, 'mod')),'mod() forbidden') assert(isempty(strfind(filetext, 'java')),'java forbidden')

2   Pass
x = 1; assert(isequal(dec_2_binvec(x),1))

3   Pass
x = 5; assert(isequal(dec_2_binvec(x),[1 0 1]))

4   Fail
x = 1000; assert(isequal(dec_2_binvec(x),[0 0 0 1 0 1 1 1 1 1]))

Assertion failed.

5   Fail
x = 2700; assert(isequal(dec_2_binvec(x),[0 0 1 1 0 0 0 1 0 1 0 1]))

Assertion failed.

6   Fail
x = 8210; assert(isequal(dec_2_binvec(x),[0 1 0 0 1 0 0 0 0 0 0 0 0 1]))

Assertion failed.

7   Fail
x = 44580; assert(isequal(dec_2_binvec(x),[0 0 1 0 0 1 0 0 0 1 1 1 0 1 0 1]))

Assertion failed.