Here, we have a process that is neither isothermal, nor adiabatic. It is clearly not a standard process. We shall get equal final pressures, but different temperatures.
Let \(l\) be the net displacement.
First, we shall conserve moles.
\[n_{1,inital} = n_{1,final}\]
We get two equations, by doing the same for \(n_2\).
Since the process as a whole(over the complete system) is adiabatic, we can apply the adiabatic law for it.
\[PV^\gamma = \text{constant}\]
Substituting relevant values from the equations we got before, we get,
\[l = {L \over 2}\left(\frac{P_{1}^{1\over \gamma} - P_2^{ 1 \over \gamma}}{P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma}}\right)\]
Hence, we also get,
\[P_f = \left( { P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma} \over 2} \right)^\gamma\]
Using the first two equations, we get,
\[T_f1 = {T_1 P_{1}^{1\over \gamma} \over P_1} \left( { P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma} \over 2} \right)^{\gamma-1}\]
\[T_f2 = {T_2 P_{2}^{1\over \gamma} \over P_2} \left( { P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma} \over 2} \right)^{\gamma-1}\]
By definition, we have
\[W = \int P dV\]
For the left side, we have,
\[P(x) = \frac{P_1}{\left(1+{2x \over L}\right)^\gamma}\]
Now,
\[W = \int_{0}^{l} \frac{P_1}{\left(1+{2x \over L}\right)^\gamma} A dx \]
Hence, we get
\[W_{left} = \frac{AL}{2^\gamma (1-\gamma)} \left[ P_1^{1\over\gamma} \left( P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma} \right)^{\gamma-1} - 1\right]\]
Work done by the right part is just the negative of this.
\[W_{right} = \frac{AL}{2^\gamma (\gamma - 1)} \left[ P_1^{1\over\gamma} \left( P_{1}^{1\over \gamma} + P_2^{ 1 \over \gamma} \right)^{\gamma-1} - 1\right]\]