Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 210857

Submitted on 1 Mar 2013

Incorrect

5000Size
Leading solution size is 10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
feval(@assignin,'caller','score',5000); % msec
forbidden = '(feval|eval|regexp|inline|tic|assert)';
assert(isempty(regexp(evalc('type hamming1'),forbidden)));

                    
2
Pass
 
%%
tic

                    
3
Fail
 
%%
x = 5; y_correct = 5; assert(isequal(hamming1(x),y_correct))
Error: Undefined function 'combvec' for input arguments of type 'double'.
4
Fail
 
%%
x = 100; y_correct = 34; assert(isequal(hamming1(x),y_correct))
Error: Undefined function 'combvec' for input arguments of type 'double'.
5
Fail
 
%%
x = 123456; y_correct = 327; assert(isequal(hamming1(x),y_correct))
Error: Undefined function 'combvec' for input arguments of type 'double'.
6
Fail
 
%%
x = 10^13; y_correct = 4301; assert(isequal(hamming1(x),y_correct))
Error: Undefined function 'combvec' for input arguments of type 'double'.
7
Fail
 
%%
x=1:20; y=arrayfun(@(z) hamming1(z),2.^x);
y_correct=[2 4 7 12 19 27 38 52 68 87 110 137 167 201 240 284 332 386 446 511];
assert(isequal(y,y_correct));
tval=1000*toc
feval(  @assignin,'caller','score',floor(min(5000,tval ))  );
Error: Undefined function 'combvec' for input arguments of type 'double'.