I am trying to solve this problem right from the morning but I am still unsuccessful.

Its very simple(as we have the answers) to say:

x^x + y^y = 31 = 4 + 27 = 2^2 + 3^3

x^y + y^x = 17 = 8 + 9 = 2^3 + 3^2

So comparing both sides of the equations, we see that x = 2 and y = 3

Can the MHF helpers please throw some light on what method is to be adopted to solve this type of problem?