To find the length of the third side of the triangle, we can use the information given about the perimeter of the triangle. The perimeter of a triangle is the sum of the lengths of all its sides.
Let:
- \( a = 5 \) cm (one side of the triangle)
- \( b = 7 \) cm (another side of the triangle)
- \( c \) = unknown length of the third side
We know that the total distance traveled by the ant, which is the perimeter of the triangle, is 20 cm. Therefore, we can set up the equation:
\[ a + b + c = 20 \]
Substituting the known values:
\[ 5 + 7 + c = 20 \]
Now, simplifying the equation:
\[ 12 + c = 20 \]
To find \( c \), subtract 12 from both sides:
\[ c = 20 - 12 \] \[ c = 8 , \text{cm} \]
Thus, the length of the third side of the triangle is \( \boxed{8} \) cm.