My last post was a little tiling puzzle: you can read it here. In this post I want to quickly give the solution.
Represent a red tile by 1 and a blue tile by −1; and think of the square in coordinate (a,b) as the monomial xayb. Then the question is equivalent to asking when the polynomial pN,M(x,y)=∑Na=1∑Mb=1xayb is in the ideal generated by (1−x+x2,1−y+y2). These are cyclotomic polynomials for sixth roots of unity, so one can test whether pN,M(x,y) is in this ideal by evaluating it at (ζ,ζ), where ζ is a primitive sixth root of unity. Now it’s an exercise to check that pN,M(ζ,ζ)=0 if and only if one of N,M is divisible by 6!