Cody

# Problem 1097. USC Fall 2012 ACM Question A : Read Input File

Solution 481866

Submitted on 3 Aug 2014 by rifat
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
%% tic urlfn='http://contest.usc.edu/index.php/Fall12/Home?action=download&upname=codes.in.txt'; urlwrite(urlfn,'codesin_A.txt'); % Load file from USC toc for trial=1:3 ptr=randi(17); A_USC = USC_file(urlfn,ptr); fid=fopen('codesin_A.txt','r'); qty=fscanf(fid,'%i',1); for q=1:ptr nr=fscanf(fid,'%i',1); nc=fscanf(fid,'%i',1); A=zeros(nr,nc); for i=1:nr strv=fscanf(fid,'%s',1); % Reads a line of text A(i,:)=strv-'0'; % vectorize the string end strv=fscanf(fid,'%s',1); Test=strv-'0'; end fclose(fid); assert(isequal(A,A_USC)) end % trial toc

Elapsed time is 1.258696 seconds. [Warning: File 'codesinput.txt' not found.] [> In USC_file at 3 In verifyCode>evaluateCode at 238 In verifyCode at 43 In fevalJSON at 14] R = '3' '3' R = '4' '2' R = '10' '1' R = '1' '100' R = '1' '1' R = '1000' '100' R = '1000' '100' R = '1000' '100' R = '1000' '100' R = '1000' '100' R = '100' '100' R = '745' '36' R = '1' '1' R = '3' '3' R = '4' '2' R = '10' '1' R = '1' '100' R = '1' '1' R = '1000' '100' R = '3' '3' R = '4' '2' R = '10' '1' Elapsed time is 3.465433 seconds.