Mrs. Larson gave some sweets and cookies to Chad and Dorothy. Each of them took half of each food item. Chad ate 18 sweets and gave half of his remaining sweets to Dorothy. Dorothy ate 28 cookies and gave 1/3 of her remaining cookies to Chad. In the end, the ratio of the number sweets Chad had to the number of sweets Dorothy had was 2:15. The ratio of the number of cookies Chad had to the number of cookies Dorothy had was 15:4. How many sweets and cookies did each of them have at first?

This question can be easily solved assuming two variables x and y one each for sweets and cookies.

Let the number of sweets and cookies the
x and y respectively
Sweets
Chad x/2
Cookies
Chad y/2
Sweets
Dorothy x/2
Cookies
Dorothy y/2
Chad ate 18 sweets. So sweets left- with him = x/2 - 28 = x-36/2
He gave that of his remaining sweets to Dorothy.
Then mean he kept x-36/4 sweets with him
and gave x-36/4 sweets to Dorothy
So number of sweets Dorothy has is x/2 + x-36/4 = 3x-36/4
Dorothy ate 28 cookies. So cookies left with him = y/2 - 28 = y-56/2
He gave one-third of her remaining cookies to Chad. The means she kept 2/3(y-56/2) = y-56/3
cookies with them and gave 1/3(y-56/2) = y-56/6
cookies to Chad
So number of cookies Chad than is y/2 + y-56/6 = 4y-56/6 = 2y-28/3

There fore new arrangement is
Sweets
Chad x-3/4
Cookies
Chad 2y-28/3
Sweets
Dorothy 3x-36/4
Cookies
Dorothy y-56/3
No: of sweets with Chad
———————————— = 2/15
No: of sweets with Dorothy

x-36/3x-36 = 2/15
15x - 540 = 6x - 72
9x = 468
x = 52
No: of cookies with Chad
———————————- = 15/4
no: of cookies with Dorothy
2y/28/y-56 = 15/4
8y - 112 = 16y - 840
-7y = -728
y = 104
∴ Each of them had x/2 = 26 sweets with them
and
Each of them had y/2 = 52 cookies with them