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 286934

Submitted on 22 Jul 2013 by J.R.! Menzinger

Correct

36Size
Leading solution size is 30.
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
 
fid=fopen('Cody_64.txt','w');
 fprintf(fid,'%s\n','308436464205151562 1850618785230909388');
 fprintf(fid,'%s\n','760961177192651897 1521922354385303795');
 fprintf(fid,'%s\n','23875933057623902 1098292920650700527');
 fprintf(fid,'%s\n','1000 2000000000000000000');
fclose(fid);

                    
2
Pass
 
%%
% This section has no assert to show the values being returned
Q=4;
fn='Cody_64.txt';
m=read_input64(Q,fn)
m =
   308436464205151562  1850618785230909388
   760961177192651897  1521922354385303795
    23875933057623902  1098292920650700527
                 1000  2000000000000000000
3
Pass
 
%%
Q=4;
fn='Cody_64.txt';
m=read_input64(Q,fn)
m_exp=[uint64(308436464205151562) uint64(1850618785230909388);uint64(760961177192651897) uint64(1521922354385303795);uint64(23875933057623902) uint64(1098292920650700527);1000 2000000000000000000];
assert(isequal(m,m_exp));
m =
   308436464205151562  1850618785230909388
   760961177192651897  1521922354385303795
    23875933057623902  1098292920650700527
                 1000  2000000000000000000
4
Pass
 
%%
Q=4;
m_exp=randi(2^31,Q,2);
fn='Cody_64a.txt';
fid=fopen(fn,'w');
for i=1:Q
 fprintf(fid,'%s %s\n',num2str(m_exp(i,1)),num2str(m_exp(i,2)));
end
fclose(fid);
m=read_input64(Q,fn);
assert(isequal(m,m_exp))

                    
5
Pass
 
%%
Q=8;
m_exp=randi(2^31,Q,2)*2^19;
fn='Cody_64.txt';
fid=fopen(fn,'w');
for i=1:Q
 fprintf(fid,'%s %s\n',num2str(m_exp(i,1)),num2str(m_exp(i,2)));
end
fclose(fid);
m=read_input64(Q,fn);
assert(isequal(m,m_exp))