Finding first solution, in pseudo-code:
function first : boolean; if not neighbor.first then return false repeat for row := 1 to 8 do if not neighbor.canAttack(row, column) then return true until not neighbor.next return false end