Displacement and distance are two different things, distance is the total distance traveled, this would be easy in the case of the ant, that would simply be 15+25= 40cm.
But, displacement is the 'birds eye' distance between two points, in this question it can be worked out using Pythagoras. (there is a right angled triangle) imagine the base of this triangle is the east direction and north being the upright. then the displacement would be the largest side of the triangle, or the hypotenuse.
Pythagoras said that A^2 + B^2 = C^2
where C is the hypotenuse.
so 15^2 + 25^2 = C^2
C^2 =850
simply square root this to get C
sqrt(850) = 29.15 cm
29.15 cm displaced by the ant