complete the Candy problem