To figure out how far away an earthquake is you just need one seismograph but to pinpoint where the earthquake happened, it's epicenter, you need three seismographs in three different locations.
Say an earthquake occurs at some unknown location $(x_0,y_0)$ on a 2D plane. It will emit seismic waves which travel through the Earth and are detected by seismograph stations. More than one type of wave is emitted but we'll just consider the faster compressional P-waves which travel at around $v = 6 \; \text{km/s}$ and arrive at the seismographs first.

Given the position of three seismographs $(x_i,y_i)$ and arrival time of the seismic waves at each seismograph $t_i$ where $i=1,2,3$ as inputs, determine and return the earthquake's epicenter $(x_0,y_0)$.

Input:
$(x_i,y_i)$ in kilometers where $-100 < x,y < 100$ and $t_i$ in seconds for $i=1,2,3$.

Output:
The earthquake's epicenter $(x_0,y_0)$ in kilometers.

You must be logged in to submit code but you can play around with the editor.

Notes

The whole process of using points, distances, and circles to determine the location of another point (in our case the earthquake) is called trilateration.

Earthquakes usually happen below the surface so technically the epicenter is the location on the Earth's surface below which the earthquake occured while the earthquake's focus is where it actually happened inside the Earth.

We're also assuming that the earthquake happens very close to the surface and that the seismographs are close to each other so the Earth's curvature is negligible. When the seismographs are far apart which is typical for earthquakes that happen below the ocean or when the earthquake happens deep below the ground, the Earth's spherical shape matters a lot.

The actual velocity of the P-waves can vary quite a bit depending on the medium it's traveling through. We picked a typical value of 6 km/s which is roughly the velocity of a P-wave at the Earth's surface.