Bending Spoons Interview Question

They ask a logic problem where I was supposed to find a coding solution to an optimization problem about candies.