Solution to Pythagorean theorem problem