Xavier had four containers, A, B, C and D, containing a total of 270 sweets. He

moved 10 sweets from A to B, 20 sweets from B to C and 30 sweets from C to D.
The ratio of the number of sweets in A to the number of sweets in B to the number
of sweets in C changed from 3: 7: 10 to 1:5: 8. How many sweets were in
container D at first?

2 answers

original:
A --- 3x
B --- 7x
C --- 10x
D --- y

3x+7x+10x + y = 270

13x + y = 270

after sweet movements:
A = 3x-10
B = 7x+10 - 20 = 7x - 10
C = 10x + 20 - 30 = 10x - 10
D = y + 30

3x-10 : 7x - 10 : 10x - 10 = 1 : 5 : 8
then:
(3x-10)/1 = (7x-10)/5
15x - 50 = 7x - 10
8x = 40
x = 5
and
(10x-10)/(3x-10) = 8/1
24x - 80 = 10x - 10
14x = 70
x = 5 , good, we have consistency

then in 13x+y = 270
y = 205

A had 15, B had 35, C had 50, and

D had 205 at the start

check:
ratio of A:B:C = 15:35:50 = 3:7:10 , as stated
after the exchange:
A had 5, B had 25, C had 40 and D had 235
new ratio:
A : B :C = 5:25:40 = 1 : 5 : 8 , as required.

Looks like may answer is correct
3x +7x + 10x + y = 270
20x + y = 270

(3x - 10) + (7x - 10) + (10x - 10) + y + 30 = 270
270 - 100 = 170