Cody

Solution 1540754

Submitted on 26 May 2018 by William
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   Pass
x = 1000; assert(isequal(dec_2_binvec(x),[0 0 0 1 0 1 1 1 1 1]))

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

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

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