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 182771

Submitted on 29 Dec 2012 by Alfonso Nieto-Castanon

Correct

4000Size
Leading solution size is 0.
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',8000);

                    
2
Pass
 
%%
filetext = fileread('encode_decode.m');
% Avoid Size 0 solutions
assert(isempty(strfind(filetext, 'persistent')))
assert(isempty(strfind(filetext, 'global')))

                    
3
Pass
 
%%
x=randi(2^32-1,1000);
dirfiles_orig=dir;
num_orig=size(dirfiles_orig,1);
fname=encode_decode(x);
dirfiles=dir;
num_encode=size(dirfiles,1);
c=dir(fname);
fprintf('Bytes %i\n',c.bytes)
file_size=floor(c.bytes/1000);
assert(num_encode==num_orig+1,'Virus Detected');
xout=encode_decode(fname);
assert(file_size<4100,sprintf('File Size %i\n',file_size))
assert(isequal(x,xout),'xout ~= x')
feval(  @assignin,'caller','score',floor(min( 8000,file_size ))  );
Bytes 4000000