Let the ladder in initial position be represented by a straight line AB with point A on the wall and B on the ground. Let O be the point where perpendiculars from point A on the wall and from point B on the ground meet the common edge of the wall and ground.

Hence AO = 8, BO = 6, therefore triangle AOB being a right angle , AB, the hypotenuse = √(8² + 6²) = 10 (Please calculate and verify yourself from Pythagoras theorem).

Now let ladder's position be CD in second position with C on the wall and D on the ground., such that OD = 8. Now triangle COD is a right angle triangle, with hypotenuse CD = 10, one side OD = 8, you can use Pythagoras theorem and find

CO = √(10² - 8²) = 6.