A rigid cylinder contains a freely moving piston. Initially, it divides the cylinder into equal volumes, and each side of the piston contains 1 mole of an ideal gas at $5^{\circ}C$ and $1$ bar. An electrical resistance heater is installed on side A of the piston and is energized to slowly heat the gas on side A to $170^{\circ}C$. If the tank and the piston are perfect insulators, calculate the heat added to the system by the resistance heater. The molar heat capacities of the gas are: $C_v= (3/2)R$ and $C_p=(5/2)R$.
My approach: We can calculate $P,V,T$ of both sides initially. Then some heat $Q$ is added to the system. $A$ is heated up and the piston is pushed towards $B$. Therefore some work is done on $B$ and some work is lost by $A$. We can calculate the total $\Delta U_A = nC_v\Delta T$. We can use the adiabatic relationships $PV^\gamma = k$ or $TV^{\gamma -1} = k'$ on system $B$. However, we do not know the exact volume lost by $B$ to get the final results. We can say that the final pressures on both sides are the same because the piston is in equilibrium. Although, I still have one degree of freedom. How do I calculate work without knowing the final volume? And following that, how do I calculate the heat added to the system?