Consider the following problem:
There is an integer in each square of a $8 \times 8$ chessboard. In each move you can add $1$ to each of the integers in a smaller $4\times 4$ or $3 \times 3$ square. Can you always get a table with an entry divisible by $2$?
This problem can be solved by invariance. But the invariant quantity is quite difficult to invent. I tried; but I couldn't do it. The invariant quantity, it turned out was the fact that the sum of numbers in all the rows except the third and the sixth was invariant $mod\space 2$. After solving a couple of such problems (unsuccessfully), it started seeming to me that many such problems were hit-and-trial.
I don't think that this is what mathematics is about. There must be some underlying logic to the approach to the solution. In general, how can we approach such mathematical problems which appear to be pure hit-and-trial?