First, always start with a balanced chemical reaction (in terms of x and y).
Second, by
Avogadro's law, the volumes of your gases will be proportional to the number of moles of each gas. So, for example, you could restate the problem as saying:
1 mol of a hydrocarbon, CxHy, were exploded with an excess of oxygen. The total number of moles of gas went down by 3mol. When the products were treated with sodium hydroxide (which reacts with carbon dioxide), there was a a loss of 3 mol of gas. Deduce the formula of the hydrocarbon, given that all volumes were measured under the sama conditions.
You could also approach the problem by just thinking about conservation of mass (for example, the number of carbon atoms on both sides of the equation must be the same).