Let N be the number of cups of liquid in the barrel. This is pure wine to start with.
At any point in time, the concentration of wine is defined as the amount of pure wine in the barrel divided by N.
Let C1 be the concentration of wine in the barrel at the beginning of the first day before anything is removed that day.
Let C2 be the concentration of wine in the barrel at the beginning of the second day before anything is removed that day.
Let C3 be the concentration of wine in the barrel at the beginning of the third day before anything is removed that day.
We know that C1=1.
During the first day, three cups of liquid are removed from the barrel. Those three cups contain 3 *C1 cups of pure wine.
That means the concentration of wine in the barrel at the end of the first day (and the beginning of the second day) is
C2=(N - 3*C1) / N
During the second day three more cups of liquid (this time it is diluted) are removed from the barrel. Those three cups contain 3*C2 cups of pure wine. That means the concentration of wine in the barrel at the end of the second day (and the beginning of the third day) is
C3 = (N - 3*C1 - 3*C2) / N
During the third day, three more cups of diluted liquid are removed from the barrel. Those three cups contain 3*C3 cups of pure wine. That makes the concentration of wine in the barrel drop to
C4 = (N – 3*C1 – 3*C2 – 3*C3) / N
which we are told should be 0.5
Plug the equation for C1 into the one for C2, then plug that in to the equation for C3 then plug that into the equation for C4 .
Set C4 equal to 0.5 and solve the resulting cubic to get 14.542 cups of wine in the barrel to start with.