I need to allocate a winner among the token holders. I want to keep the concept that the more tokens someone buys the more chance there will be that he will be the winner.
now lets say 960 tokens are sold in following manner: wallet A purchased 300 tokens wallet B purchased 20 tokens wallet C purchased 400 tokens wallet D purchased 240 tokens
total sold tokens = 960 total holders = 4
I will be choosing a random number between the range 1-960. Let's say choosen number is 80, this means wallet A is the winner because he owns first 300 tokens.
How shall I implement this with least gas cost?