For simplicity lets say it doesn't interact with other species in the system. I don't think I'm explaining this correctly, but I'll go through an illustrative example.
Goal: Lets say to make 1,3-dichlorohexane in as few steps as possible. Starting from the same propane derivative.
A Priori Knowledge: We could just look at this problem visually, and already come up with some efficient paths, but lets try to think of a program to do it instead. We could make a very efficient program that analyzes 1,3-dichlorohexane, and looks for different cuts it can make to see how we can couple this molecule from simpler parts (kinda like a retrosynthetic approach). But instead, lets make something much-much-much less efficient, lets purposefully make the program use evolution and natural selection principles as the engine to solve this problem; we do this because, it'll free us to do other cooler things later on.
Constructs: Lets say a molecule's DNA codes for all the synthetic steps it takes to make it, from a particular starting material. We will also say all molecules are asexual, and don't interact with any of the other molecules.
Begining: Lets say we have a 100 molecules. In the 1st generation, one random reaction will happen to every molecule. Some reactions will do nothing, others will change the functional group, others may actually lengthen the carbon-carbon backbone. But each molecule will now have an associated reaction with it, and we will add that reaction to the molecule's DNA. As the DNA is the history of all the reactions done to the individual molecule.
Selection: We then say that the best molecule, in this collection of 100, are those that have functional groups similar to the target and molecules that have a carbon-carbon backbone that is more similar to the target. We then kill off 50 of the 100 molecules that are most dissimilar. We allow the remaining molecules to "asexually divide" and make an other set of 100 molecules. Then we again react this new set of 100 molecules to another random series of synthetic reactions.
and repeat the whole process several times.
Mutations: We can also say when a molecule "asexually divides" it doesn't always copy it's synthetic history (DNA) correctly and a piece of the DNA can be deleted or inserted 10% of the time.
After many generations: We will have a system that is populated with a bunch of molecules that are the target or look very close to it. We could also be selecting on minimum synthetic steps, so not only will this system contain many of the target molecules, but hopefully also many target molecules with as few synthetic steps as possible.
Thus in the end, it isn't the greatest program for the original task, but it does end up being a generalized powerful program that allows one to play with a bunch of variables to drive synthesis towards the selection of molecules that have properties that you are looking for.
The driving variables in this case was functional groups, correct chain length, and minimum synthetic steps. But other variables we could of selected for was cost, or yield, or how well the molecule fits in active sites, or whatever your heart wants.