When writing the chemical formula, the element(s) or compound(s) exchange their valencies. The sulphur has that of the aluminium element's valency (3) and so the value of
y will also be the valency for sulphur
The atomic number for sulphur is 16 so on the electronic configuration, sulphur will have 2,8 and 6 on the last shell.
In order for sulphur to attain stability, it has to gain 2 electrons to make it 8 in the last shell, hence the valency of sulphur is
2 and so the value of
y will be 2 (the valency of sulphur)
NOTE: The atomic number for aluminium is also 13 , hence the electronic configuration will be 2,8 and 3. Aluminium could lose its 3 electrons in order to be stable, hence the valency of aluminium is also 3
Hence the chemical formula for aluminium sulphide is
Al2S3