applying PV=nRT for hydrogen
n=2 mole
let the mole of magnesium be x and mole of aluminium be y
Mg + 2Hcl---MgCL2 +H2
Al +3Hcl ----AlCl3 +1.5H2
NOW
24x +27y=39
x +1.5y=2
solving these two equation we get x=.5 ,y=1 percentage of magnesium=30.76% percentage of lauminium=69.24%