Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cannot_hit=b_dxball(n,positon,start)
- hit=0;
- for i=1:1:n
- %odd-odd or even_case
- if( ( (rem(start(1),2)==0 && rem(start(2),2)==0) || (rem(start(1),2)==1 && rem(start(2),2)==1) ) )
- 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) )
- hit = hit + 1;
- end
- %odd_even case
- elseif( ( (rem(start(1),2)==0 && rem(start(2),2)==1) || (rem(start(1),2)==1 && rem(start(2),2)==0) ) )
- 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)
- hit = hit + 1;
- end
- end
- end
- cannot_hit = n - hit;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement