How do we represent a molecule in text form?
A molecule, as a computer scientist I see it as a connected graph of atoms. A connected graph means that beginning at any atom, there is a path to any other atom in the graph.
The interesting question is, how do we represent these as text?
Specific questions are:
Is H2O$\ce{H2O}$ different than OH2$\ce{OH2}$? That is, does order matter, or what does order mean?
What does this mean NH4NO3$\ce{NH4NO3}$? Why do we write N two times? Is this the same thing NNH4O3$\ce{NNH4O3}$?