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 175704

Submitted on 10 Dec 2012 by Tim

Correct

45Size
This is the leading solution.
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
 
%%
% Armegeddon
tic
urlwrite('http://contest.usc.edu/index.php/Spring12/Home?action=download&upname=armageddon.in.txt','armageddon.in.txt')
toc
ans =
/users/msssystem2/armageddon.in.txt
Elapsed time is 1.337482 seconds.
2
Pass
 
%%
 fid=fopen('armageddon.in.txt','r');
 t_expect=[0.00 -1 20.55 -1 -1 28.38 -1 11.03 2.62 4.22 13.15 9.94 61.33 13.56 -1];
 qty=fscanf(fid,'%i',1);
 for q=1:qty %qty
  n = fscanf(fid,'%f %f %f %f \n',4)'; % dist, angle, vel A, vel Missile
  xa=n(1);
  angle=n(2);
  va=n(3);
  vm=n(4);
  [t]=Armageddon(xa,angle,va,vm) ;
  assert(isequal(t,t_expect(q)))
  end
 fclose(fid);
toc
Elapsed time is 2.307596 seconds.