Work and Time Problem : Fill Pipes and Drain Pipes : 2 
A fill pipe can fill a tank in $20$ hours, a drain pipe can drain a
tank in $30$ hours. If a system of $n$ pipes (fill pipes and drain
pipes put together) can fill the tank in exactly $5$ hours, which of
the following are possible values of $n$? Options are $32,54,29 \text{ and } 40.$

My $1st$ approach : -
Let the number of fill pipes be $a$ and hence the number of drain pipes will be $n-a$. As per the question ;
$\frac{a}{20} - \frac{n-a}{30}= \frac{1}{5}$
$\Rightarrow n= \frac{5a-12}{2}$ and we can say from the above equation that $n$ should be a multiple of $2$ and hence the possible values of $n$ can be $32,54 \text{ and } 40.$ But to my shock this is the wrong answer.
My $2nd$ approach : -
Let the number of fill pipes be $n-a$ and hence the number of drain pipes will be $a$ (Opposite of what I did in my previous approach). As per the question ;
$\frac{n-a}{20} - \frac{a}{30}= \frac{1}{5}$
$\Rightarrow n= \frac{5a+12}{3}$ and we can say from the above equation that $n$ should be a multiple of $3$ and hence the possible values of $n$ can only be $54.$ But to my shock this is also the wrong answer.
Considering both the cases the common answer should be the answer and hence the option should be 54, right?
Why there is conflict in answers using the two above approach of mine? What I am doing wrong? Please help me with this. How can these types of questions be solved easily?
Thanks in advance !
 A: Suppose there are $a$ fill pipes and $b$ drain pipes; then $\frac a{20} - \frac b{30} = \frac15$ gives $3a - 2b = 12$.
We now have to be careful. If we get an expression like $a = \frac{12+2b}{3}$, that doesn't tell us $a$ is a multiple of $3$. It tells us that $12+2b$ is a multiple of $3$ (otherwise, $\frac{12+2b}{3}$ will not be an integer).
I prefer to think of it a different way. In the expression $3a-2b=12$, $3a$ and $12$ are both divisible by $3$, so the remaining term $2b$ must also be divisible by $3$, which means $b$ is divisible by $3$. Also, $2b$ and $12$ are both divisible by $2$, so the remaining term $3a$ must also be divisible by $2$, which means $a$ is divisible by $2$.
Anyway, now we can set $a=2x$ and $b=3y$ to get $6x- 6y=12$, or $x-y=2$.
All solutions $(x,y)$ are of the form $(y+2,y)$ where $y$ is a nonnegative integer, and so all solutions $(a,b)$ are of the form $(2y+4, 3y)$ where $y$ is a nonnegative integer. The total number of pipes is $5y+4$, which tells you the restriction on $n$.
A: From your first solution you get:
$$
a={2n+12\over5}
$$
and only $n=54$ and $n=29$, among the given solutions, make $a$ an integer. The same result, obviously, with your second solution.
