Mark's implementation of the molecule weighing problem