added logic for solver that checks rows, columns, and grids