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 198380

Submitted on 30 Jan 2013 by Alfonso Nieto-Castanon

Correct

47Size
Leading solution size is 45.
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/msssystem9/armageddon.in.txt
Elapsed time is 0.212994 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 0.290284 seconds.