Let the number of sweets each had at the end be X. The total number of sweets was 3X.
The number of sweets Max had before was X+9+23=X+32.
The number of sweets Ruby had was X-9, and the number Steve had was X-23.
The number of sweets Ruby and Steve initially had was X-9+X-23, so (2X-32)/(X+32)=2/3.
Cross multiplying: 3(2X-32)=2(X+32), 6X-96=2X+64, 4X=96+64=160, so X=40.
Now let’s check. There were 120 sweets initially. Max had 72, Steve had 17 and Ruby had 31. The total number that Steve and Ruby had between them was 48, and 48:72 is 2:3.
Max gave 9 to Ruby leaving him with 63, so Ruby had 40, then he gave 23 to Steve leaving him with 40 and Steve with 40. So they all ended up with 40.