Advertisement
Guest User

Untitled

a guest
Jun 12th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement