A new approach based on the Monte Carlo method of solving molecular crystal structures from full-pattern profile analysis of powder diffraction data is described. The new approach represents a significant advance on previous Monte Carlo methods in that it permits the solution of flexible (i.e. with variable bond lengths, bond and torsion angles) molecules. It does this by not only allowing random rotations and translations of individual atoms and rigid-body fragments comprising an asymmetric unit, but by permitting changes of internal configuration of stereochemically constrained moieties. The last option was crucial in the case of the structure solution of poly(ethylene oxide)3:LiN(SO2CF3)2, containing 25 non-H atoms in the asymmetric unit. Using a specifically designed computer code the atomic positions of the flexible poly(ethylene oxide) [(CH2-CH2-O),] chain and imide N(SO2CF3) 2-group are described in terms of bond lengths, angles and torsion angles, offering a means of introducing chemical constraints which, in turn, significantly reduce the number of parameters to be varied in a random fashion. Furthermore, tests for reasonable inter-fragment distances avoid the unnecessary calculation of chemically unreasonable structures. A detailed account of the random-search procedure combined with simulated annealing is given.