Heureka, your answer is correct if a box is restricted to a maximum of one piece of candy.
nCr(4, 1) + nCr(3, 2) = 12
Reasoning:
There are nCr(4, 1) = 4 ways to place the unique piece of candy in one of the four (4) boxes. Then the 2 indistinguishable candies can be placed in the other 3 boxes nCr(3, 2) = 8 ways. There are (4+8) = 12 ways to distribute the candies.
If there are no restrictions on the maximum then:
\(\hspace{15pt} \left( \dfrac{4!}{2!}\right)* \left(2 \right) \;+\; \left( \dfrac{4!}{2!}\right) \;+\; \left(4\right)\\ \text {Reasoning:}\\ \text {All candy in 1 of 4 boxes (4 ways)}\\ \text {2 combinations (XX|Y & XY|X) distributed to boxes in (2)(4*3) = (2)(4!/2!) =(24) ways;}\\ \text {and 1 candy to each box distributed to boxes in (1)(4*3*2)/2 = 4!/2! = (12) ways.} \\ \text {Total 4+24+12 = 40 ways.} \)
(Adapted from Nauseated’s solution https://web2.0calc.com/questions/i-really-need-help-please-i-have-no-idea-how-to-do-it-sorry#r4)
GA