Hi

First the % spent on B was not 50%.

However if you know the % you can do the following:

For B quantity=% of total value/unit price

For A:

First rough guess by doing remaining total value/0.23

If the result is > 150 (and in this case it is) then you have at least 150*0.23

so for the remainder (total value remaining-(150*0.23))/0.18

Hope that makes sense