Lucy went to the grocery store. She bought w packs of cookie and x packs of cake. How many more packs of cookie did she buy over cake?
Let's say that one pack of cookies is c and one pack of cake is k. 

Lucy went to the grocery store. She bought w packs of cookie and x packs of cake.

This means that:

c*w+k*x=constant

We need to find out how many more packs of cookie she bought over cake. In other words, we need to find out how many more c's there are than k's. 

This is the same as saying that we need to find out how many more c's there are than k's in the equation:

c*w+k*x=constant

We can do this by subtracting kx from both sides:

c*w+k*x-k*x=constant-k*x

c*w=constant-k*x

c*w/c=constant/c-k*x/c

w=constant/c-k*x/c

w=constant/c-(constant/c-w)/x

w=constant/c-(constant-c*w)/x

w