This problem involves a joint rate. A key to joint rate problems is that rates add.
The rate for pipe a , Ra , is Ra = 1/6 (unit is tanks per hour)
The rate for pipe b, Rb , is Rb = 1/8 (unit is tanks per hour)
The joint rate, RJ , is thus RJ =1/6 + 1/8 = 7/24 (tanks per hour)
Let the number of hours for which both pipes run be x , and consequently, the number of hours for which only pipe a runs will be 4 -x
The condition that the tank be filled in 4 hours is then:
1 = RJ x + Ra (4-x)
1 = (7/24) x + (1/6) (4-x)
Solving for x gives x = 8/3