If you convert the number in each row to binary and then "add" them you can figure out if it is a winning combonation. If there are an even number of "switches" that are on in each column then it is a winning combonation, for instance:
If I had 111 I convert that to binary 011 11 010 1 001
There are an even amount of "ons" in each column so this is a winning combonation.