Question 1188238
Let new cards be x 
(x - x/10) + 45 = 9x/10 + 45
1/3 of (9x/10 + 45) = 9x/30 + 45
(9x/10 + 45) - (9x/30 + 15) + 40 = 160
=> 9x/10 - 9x/30 + 70 = 160
=> (27x - 9x)/30 = 90
x = (90 * 30)/18
= 15 * 10
= 150 cards 

ratio method:
He has 160 cards in the end.
He bought 40 new cards.
So, He had (160 - 40) = 120 cards.
He used 1/3 of the new total no. of cards.
Then,
He used : He not used
= 1 : 2
60 : 120
Then no. of total new cards is 120 + 60 = 180
He bought 45 new cards .
Before buying 45 cards he had,
(180 - 45) = 135 cards.
He gave Alan 1/10 of the cards.
Justin : Alan
9 : 1
135 : 15
So, At first Justin had
(135 + 15) = 150 cards.