% In order to use this M-file do as follows in a MATLAB command windows

   %  a/ clear the workspace using   clear  and then type clc
   %>> clear; clc
   %  b/ run your submitted M-file as shown below (my  M-file is named p1_1234.m)
   %>> p2_1234.m  
   %  c/ run this script (M-file) by typing 
   %>> p2_chck
   %  d/ A grade will be reported at the end.
   %  Note that obviously the program won't check the validity of the first few lines of
   %  your submission, nor variables v1, v2, v3, v4
   %
%
% It also does not deal with the case that a variable is not defined properly (name, case, etc).
%
%
points=70;
clear zorro;

vv11 = 1 ./ (2:1000) ;

vv10 = 1:3:80;
vv12 = vv10 - 1;

vv13 =  vv10 .^3;
vv14 =  vv10 .^ (1/5);
vv15 =  (0:999) ./ (1:1000);
vv16 = 25:-4:-3; 

vv17 = ((10:10:50) + cumsum([0 2:5]))';  % one way to do it
vv17 = (cumsum([10 12:15]))';            % another way to do it
vv18 = (-1:0.25:1)';
vv19 = sum(sum( (3*ones(400,400)+2*eye(400)-1) == 2)); 

vv20 = 20*ones(20);
vv21 = zeros(11,11); vv21(:)= (1:121) ;
vv22 = zeros(11,11); vv22(:)= (1:121);vv22=vv22';
vv23 = vv16;
vv23(1:3:7) = 250:-120:10;
vv24=sum(vv11)+1-log(length(vv11)+1);


if (exist('v10')~=1) || (isequal(v10,vv10) == false)
  fprintf('v10::   wrong        \n');
  points = points-4;
end
if (exist('v11')~=1) || (isequal(v11,vv11) == false)
  fprintf('v11::   wrong        \n');
  points = points-4;
end
if (exist('v12')~=1) || (isequal(v12,vv12) == false)
  fprintf('v12::   wrong        \n');
  points = points-4;
end
if (exist('v13')~=1) || (isequal(v13,vv13) == false)
  fprintf('v13::   wrong        \n');
  points = points-4;
end
if (exist('v14')~=1) || (isequal(v14,vv14) == false)
  fprintf('v14::   wrong        \n');
  points = points-4;
end

if (exist('v15')~=1) || (isequal(v15,vv15) == false)
  fprintf('v15::   wrong        \n');
  points = points-4;
end

if (exist('v16')~=1) || (isequal(v16,vv16) == false)
  fprintf('v16::   wrong        \n');
  points = points-4;
end

if (exist('v17')~=1) || (isequal(v17,vv17) == false)
  fprintf('v17::   wrong        \n');
  points = points-4;
end

if (exist('v18')~=1) || (isequal(v18,vv18) == false)
  fprintf('v18::   wrong        \n');
  points = points-4;
end

if (exist('v19')~=1) || (isequal(v19,vv19) == false)
  fprintf('v19::  wrong          \n');
  points = points-4;
end

if (exist('v20')~=1) || (isequal(v20,vv20) == false)
  fprintf('v20::  wrong        \n');
  points = points-4;
end
if (exist('v21')~=1) || (isequal(v21,vv21) == false)
  fprintf('v21::  wrong        \n');
  points = points-4;
end
if (exist('v22')~=1) || (isequal(v22,vv22) == false)
  fprintf('v22::  wrong        \n');
  points = points-4;
end
if (exist('v23')~=1) || (isequal(v23,vv23) == false)
  fprintf('v23::  wrong      \n');
  points = points-4;
end
if (exist('v24')~=1) || (isequal(v24,vv24) == false)
  fprintf('v24::  wrong      \n');
  points = points-4;
end

fprintf(' Final Grade for P2 is %4.1f\n',ceil(points));
