You can't. The candy machine mini-game is unwinnable by design.
It's one of those deliberately cruel touches some licensed games include — a task that looks achievable and isn't. Don't burn an hour on it; move on to the rest of the game, where the challenges actually reward effort.