This question is given as an exercise to me . I took a look at the solution given by the instructor which is not the same as my solution .
So I thought it would be wise to ask it here considering I am a newbie on that topic.
My solution basically is as follow :
S -> aSa | bSb | aTb | bTa
T-> aTa | bTb | aTb | bTa | e
My apporach to the problem is as follows : If I don't find any differences (if both characters are the same) , continue with S until you find make a difference then you can do whatever you want with the string as long as you obey the rule of x having the same lenght .