First, let's call the number of blue marbles Rosy had first #b# and the number of white marbles Rosy had first #w#.
At first Rosy had:
#b = 4w# - she had 4 times as many blue marbles as white.
Then Rosy had:
#b - 18 = w + 6# - she gave away 16 blue marbles and got 6 white marbles she had the same number blue and white marbles.
We can substitute #4w# from the first equation for #b# in the second equation and solve for #w# to find the number of white marbles Rosy had at first:
#b - 18 = w + 6# becomes:
#4w - 18 = w + 6#
#4w - 18 + color(red)(18) - color(blue)(w) = w + 6 + color(red)(18) - color(blue)(w)#
#4w - color(blue)(w) - 18 + color(red)(18) = w - color(blue)(w) + 6 + color(red)(18)#
#4w - 1color(blue)(w) - 0 = 0 + 24#
#(4 - 1)color(blue)(w) = 24#
#3w = 24#
#(3w)/color(red)(3) = 24/color(red)(3)#
#(color(red)(cancel(color(black)(3)))w)/cancel(color(red)(3)) = 8#
#w = 8#
Now, we can substitute #8# for #w# in the first equation to calculate the number of blue marbles Rosy had at first.
#b = 4w# becomes:
#b = (4 * 8)#
#b = 32#
At first Rosy had 32 blue marbles and 8 white marbles.
When she gave away 18 blue marbles away and received 6 more white marbles she had 14 blue marbles and 14 white marbles.