A certain regular tetrahedron has three of its vertices at the points $(0,1,2),$ $(4,2,1),$ and $(3,1,5).$  Find the coordinates of the fourth vertex, given that they are also all integers.
The side length of the regular tetrahedron is the distance between $(0,1,2)$ and $(4,2,1),$ which is
\[\sqrt{(0 - 4)^2 + (1 - 2)^2 + (2 - 1)^2} = \sqrt{18} = 3 \sqrt{2}.\]So if $(x,y,z)$ is the fourth vertex, with integer coordinates, then
\begin{align*}
x^2 + (y - 1)^2 + (z - 2)^2 &= 18, \\
(x - 4)^2 + (y - 2)^2 + (z - 1)^2 &= 18, \\
(x - 3)^2 + (y - 1)^2 + (z - 5)^2 &= 18.
\end{align*}Subtracting the first and third equations, we get $6x + 6z - 30 = 0$, so $x + z = 5,$ which means $z = 5 - x.$  Subtracting the first and second equation, we get $8x + 2y - 2z - 16 = 0,$ so
\[y = z - 4x + 8 = (5 - x) - 4x + 8 = 13 - 5x.\]Substituting into the first equation, we get
\[x^2 + (12 - 5x)^2 + (3 - x)^2 = 18.\]This simplifies to $27x^2 - 126x + 135 = 0,$ which factors as $9(x - 3)(3x - 5) = 0.$  Since $x$ is an integer, $x = 3.$  Then $y = -2$ and $z = 2.$  Thus, the fourth vertex is $\boxed{(3,-2,2)}.$
(3,-2,2)
Level 5
Precalculus
Problem: A certain regular tetrahedron has three of its vertices at the points $(0,1,2),$ $(4,2,1),$ and $(3,1,5).$  Find the coordinates of the fourth vertex, given that they are also all integers.
Solution:<|START_OF_LATENT|><|PRIOR_PREFIX|>To find the coordinates of the fourth vertex of a regular tetrahedron, we need to ensure that all four vertices are equidistant from each other. The given vertices are A(0,1,2), B(4,2,1), and C(3,1,5). 

First, calculate the distances between the known vertices:

1. Distance AB:
   d(A, B) = sqrt((4-0)² + (2-1)² + (1-2)²) = sqrt(16 + 1 + 1) = sqrt(18) = 3√2.

2. Distance AC:
   d(A, C) = sqrt((3-0)² + (1-1)² + (5-2)²) = sqrt(9 + 0 + 9) = sqrt(18) = 3√2.

3. Distance BC:
   d(B, C) = sqrt((3-4)² + (1-2)² + (5-1)²) = sqrt(1 + 1 + 16) = sqrt(18) = 3√2.

All distances between A, B, and C are equal, confirming they form an equilateral triangle.

Next, denote the fourth vertex as D(x, y, z). The distances from D to each of the three vertices must also equal 3√2.

Set up the equations based on the distance from D to each vertex:

1. d(D, A) = 3√2:
   sqrt((x-0)² + (y-1)² + (z-2)²) = 3√2.
   Squaring both sides gives:
   (x-0)² + (y-1)² + (z-2)² = 18.

2. d(D, B) = 3√2:
   sqrt((x-4)² + (y-2)² + (z-1)²) = 3√2.
   Squaring both sides gives:
   (x-4)² + (y-2)² + (z-1)² = 18.

3. d(D, C) = 3√2:
   sqrt((x-3)² + (y-1)² + (z-5)²) = 3√2.
   Squaring both sides gives:
   (x-3)² + (y-1)² + (z-5)² = 18.

Now we have three equations to solve for x, y, and z. 

From the first equation:
x² + (y-1)² + (z-2)² = 18.

From the second equation:
(x-4)² + (y-2)² + (z-1)² = 18 expands to:
x² - 8x + 16 + (y² - 4y + 4) + (z² - 2z + 1) = 18.

From the third equation:
(x-3)² + (y-1)² + (z-5)² = 18 expands to:
(x² - 6x + 9) + (y² - 2y + 1) + (z² - 10z + 25) = 18.

By simplifying and rearranging these equations, we can isolate variables and find integer solutions. 

After solving the system of equations, we find that the coordinates of the fourth vertex D that satisfy all conditions are (3, -2, 2).<|END_OF_LATENT|> The final answer is $(3,-2,2)$.