<h3>
Answer: 30 hours</h3>
============================================================
Explanation:
Let's consider the tank's full capacity is 240 gallons. I'm picking this number because 12*20 = 240.
If the tank is 240 gallons, then the inlet pipe can fill it at a rate of 240/12 = 20 gallons per hour. Note after 12 hours, we have 12*20 = 240 gallons filled assuming the outlet pipe is sealed shut.
At the same time, the outlet pipe is draining at a rate of 240/20 = 12 gallons per hour. After 20 hours, the outlet pipe would drain out 12*20 = 240 gallons assuming the inlet pipe is not adding any water.
With the two pipes playing this tug-of-war battle, the inlet pipe ultimately wins because it's adding more gallons of water each hour, compared to the amount drained per hour. The net change is +20-12 = 8 gallons per hour.
This means it will take 240/8 = 30 hours to fill the tank with both pipes open.
----------------------------------
Another approach:
The inlet pipe can fill the tank in 12 hours, so it gets 1/12 of the job done per hour. The outlet pipe drains the tank in 20 hours, so it gets 1/20 of the job done in one hour.
The net change is 1/12 - 1/20 = 5/60 - 3/60 = 2/60 = 1/30
This means that when both pipes are open, 1/30 of the job is done per hour. By "job", I mean "filling the tank".
If x is the number of hours needed to do one full job, then we can multiply that by the unit rate (1/30) and set the result equal to 1
(rate)*(time) = 1 job
(1/30)*x = 1
x = 30*1
x = 30
It takes 30 hours to do the job with both pipes open.