In x years.
In x years, John will be 12+x years old; Peter will be 3+x years old.
John will be 3 times as old as Peter:
12 + x = 3*(3 + x).
Simplify and find x
12 + x = 9 + 3x
12 - 9 = 3x - x
3 = 2x
x = 3/2 years.
When the age problem has no solution in integer numbers, it is TRADITIONALLY considered as DEFECTIVE.