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 175590

Submitted on 10 Dec 2012 by James

Correct

52Size
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/msssystem5/armageddon.in.txt
Elapsed time is 0.462289 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
strike_point =
   3.5079e+04
t_launch =
     0
strike_point =
   4.8865e+04
t_launch =
   -8.6700
t_launch =
    -1
strike_point =
   2.4643e+04
t_launch =
   20.5500
strike_point =
   3.5079e+04
t_launch =
   -4.6700
t_launch =
    -1
strike_point =
   3.5079e+04
t_launch =
   -4.5000
t_launch =
    -1
strike_point =
   8.8693e+03
t_launch =
   28.3800
strike_point =
   1.2361e+04
t_launch =
   -0.3400
t_launch =
    -1
strike_point =
   8.2221e+03
t_launch =
   11.0300
strike_point =
   1.1678e+04
t_launch =
    2.6200
strike_point =
   7.3869e+03
t_launch =
    4.2200
strike_point =
   1.2491e+04
t_launch =
   13.1500
strike_point =
   8.5745e+03
t_launch =
    9.9400
strike_point =
   9.6391e+03
t_launch =
   61.3300
strike_point =
   8.6814e+03
t_launch =
   13.5600
strike_point =
   1.8026e+04
t_launch =
   -2.2300
t_launch =
    -1
Elapsed time is 1.358708 seconds.