A diagram is difficult to construct on this site. But, the shortest ladder is when the horizontal side is equal to the vertical side of the triangle that the ladder makes with the barn and ground.
This means that each is 12 ft.
So, the shortest ladder L is L2 = (36/6 + 6)2 + (6 + 6)2 or L2 = 288 or L = 16.97 ft