Solving for sides of a right triangle