# Is there an algorithm for solving “Magic Squares” puzzles?

In case you don't know what I'm referring to, it would be those "lights on, lights off" puzzles where you are free to toggle the status of any light in the grid, but doing so also toggles adjacent lights (but not diagonal).

The goal is usually to toggle all of the lights on, or to match a certain pattern of lights (i.e. middle light off).

The puzzle I'm currently stumped on begins as such:

O X O
O O O
X X O


The goal is to make a T shape, or:

O O O
X O X
X O X


I can never figure out a "tried and true" method to solve these, and am wondering if there is some lovely match trick that can be used to figure them out. More often than not, I end up just toggling at random and hoping for the best.

A solution to this particular problem would be nice but I'm also looking for an "algorithm" of sorts for future puzzles.

Thanks!