SHARE
TWEET

Untitled

a guest Jun 12th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cannot_hit=b_dxball(n,positon,start)
  2.  
  3. hit=0;
  4.  
  5. for i=1:1:n
  6.     %odd-odd or even_case
  7.     if(  ( (rem(start(1),2)==0 && rem(start(2),2)==0) || (rem(start(1),2)==1 && rem(start(2),2)==1) ) )
  8.         if(  (rem(position(i,1),2)==0 && rem(position(i,2),2)==0) || (rem(position(i,1),2)==1 && rem(position(i,2),2)==1) )
  9.         hit = hit + 1;
  10.         end
  11.        
  12.         %odd_even case
  13.     elseif( ( (rem(start(1),2)==0 && rem(start(2),2)==1) || (rem(start(1),2)==1 && rem(start(2),2)==0) ) )
  14.         if(rem(position(i,1),2)==0 && rem(position(i,2),2)==1) || (rem(position(i,1),2)==1 && rem(position(i,2),2)==0)
  15.         hit = hit + 1;
  16.         end
  17.     end
  18.  
  19. end
  20.  
  21. cannot_hit = n - hit;
  22.  
  23. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top