We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n is the number of columns, n%2 will give you either 1 or 0 depending on if it is divisible by 2 or not. The same will be done with the rows using m and m%2.
This gives us (n+n%2) (which we can think of as N from here on out) is even, and (m+m%2) (which we can think of as M) is also even, and although it might be larger than the original n*m board, it makes it easier to calculate the number of bases needed since if we had an odd number we would have to add 1 base on the last row or column.
With our new N*M board, it is easy to solve since each base can fit 4 squares, 2 from the N and 2 from the M. So we do N*M/4 to get the number of bases needed.
Army Game
You are viewing a single comment's thread. Return to all comments →
n is the number of columns, n%2 will give you either 1 or 0 depending on if it is divisible by 2 or not. The same will be done with the rows using m and m%2.
This gives us (n+n%2) (which we can think of as N from here on out) is even, and (m+m%2) (which we can think of as M) is also even, and although it might be larger than the original n*m board, it makes it easier to calculate the number of bases needed since if we had an odd number we would have to add 1 base on the last row or column.
With our new N*M board, it is easy to solve since each base can fit 4 squares, 2 from the N and 2 from the M. So we do N*M/4 to get the number of bases needed.