Hello, I'm Keith and happy to help you with your question.
Your are well on the way to understanding. Your Capital Gains Tax (CGT) position is as follows.
Take the purchase price, add costs of purchase add any improvements eg new kitchen, installation of central heating, double glazing etc. Then take the sale price less the costs of sale, take one from the other and that is the capital gain.
Now work out your total ownership time in months. Ditto for the rental period and from the rental period deduct 18 months. This figure over the total ownership period is the proportion of the gain which will be subject to CGT.
From that deduct your Annual Exempt Allowance of 11K and Lettings Relief of up to 40K; that assumes that you have been declaring the gain for Income Tax.
As far as the lodgers are concerned if there were more than one then the rental figure period would be extended by that occupation time reducing the proportion adjustment figure and increasing the chargeable gain.
I do hope I have helped in this short canter through the CGT jungle; an extremely complex tax.