Work done of the gas

My homework is that : a container contains two half parts X and Y separated by a plate P. Part X contains ideal gas, while part Y is vacuum. Then the plate P is removed, so gas from X can spread out the whole container. But the most confusing part is : it is said that X does no external work, although the gas expands. Can anyone explains it to me?

I think that because vacuum has little gas molecule so gas from X cannot interact or collide with any other particles => it cannot pass on energy. Is it right?

When a gas expands, it is said to have done expansion work. Work done is given by force x distance. So in the case of a gas expanding, the force is the external pressure multiplied by the surface area. The distance travelled can be though as the height that the gas reaches. Hence our equation for work is: $$w = p_{ex}s\Delta h$$ where s is surface area and h is the height. The key thing here is that the work depends on the external pressure, i.e. the pressure of the surroundings. The work done is not related to the pressure of the system. This then can be simplified to: $$w = p_{ex}\Delta V$$ The fact that work depends on the pressure of the surroundings, not the system may seem counter intuitive at first, however this make sense. After all the force that must be applied by the expanding gas molecules depend on the external pressure that is trying to compress the gas molecules. So, in the case of your question, the external pressure is 0 as the pressure of a vacuum 0. Hence the total work done is 0. This makes sense because since the surroundings is a vacuum, there is no external pressure that is trying to resist the expansion of the gas molecules, and hence the system is able to expand freely.