Not sure how to solve it in my head. But there are two equations and three unknowns here. This suggests multiple answers (though it’s possible only one unique combination of integers has all numbers >= 1 and a sum = $20):
(x, y, z) = (# fudge, # chocolates, # candies)
x + y + z = 20 : you bought 20 items
3x + y + 1/2*z = 20 : the total bill added up to $20
–
Substituting eq 1 into 2 (I substituted y = 20 - x - z)
3x + (20 - x - z) + 1/2*z = 20 --> 2x - 1/2*z = 0 --> 4x - z = 0 --> z=4x
So whatever answer there is involves buying 4 times as many candies as fudge.
Allowable numbers of fudge are [1, 2, 3, 4, 5, 6] because 7 would cost more than $20. These would cost [$3, $6, $9, $12, $15, $18]
Corresponding numbers of candies would be [4, 8, 12, 16, 20, 24] and would cost [$2, $4, $6, $8, $10, $12]
Total sums of these pairs would be [$5, $10, $15, $20, $25, $30].
The last two would bust the budget. And the $20 wouldn’t let you buy any chocolate So the possible combinations involve (1,2,3) fudges and (4,8,12) candies, with the difference made up by chocolates (15, 10, 5).
(fudge, chocolate, candy)
(1, 15, 4) = ($3, $15, $2) = $20, 20 items
(2, 10, 8) = ($6, $10, $4) = $20, 20 items
(3, 5, 12) = ($9, $5, $6) = $20, 20 items
–
I would not be able to produce this answer without a sheet of paper, however.
Reading other people’s answers, the test was probably designed to see if you would follow the implied assumption that there was a unique answer or discover that there are multiple ones.
(or maybe they just wanted to know if you preferred to max out on fudge/candies, vs regular chocolate)