It would be helpful if the text gave an example. Also, the test suite should be much richer - only two special cases does not really encourage people to write general solutions.
This could be quite a good solution, if you removed the "x = 7; %" part and just left what is now a comment. As it is, although it satisfies the test case, it doesn't actually solve the problem.
Needs a richer test suite. A lot of "solvers" have just put a=7 as the "solution", but although this satisfies the single test case, it doesn't solve the problem as stated.
You should definitely strengthen the test suite. Lots of solutions rely on both diagonals being the same, even though this is not a property of the stated problem.
But you can't rely on x always being a magic square - that's just an accident of the inadequate test suite, isn't it? So although this *looks* like a good solution, it isn't really. I think it's bad practice to take advantage of an inadequate test suite.