Solve for asset classes

Hi, during the several practice exams I saw several issues regarding solving for asset class weight. I.e. some corner portfolios are given and you have to solve for the optimal weights to get a specific return. This works in the formula overall return = Return of portfolio 1 w + return portfolio 2 (1-w) How can I quickly solve for the weight. I tried a trial and error process so for. Is there also a function on the calculator? Thank you in advance for a feedback Greg

exapnd out the bracket. r= 7(w) + 8(1-w) r= 7w +8 - 8w , etc. This is L2 stuff.