python implentation of the Anderson Moore Algorithm