to explain what I mean, lets start with a list of items each with their own score
[2,3,4]
adding these up these gives 9, so I want to be able to select a random number in the total range, where this number would represent one of these items
item 1, score of 2, range 0-1
item 2, score of 3, range 2-4
item 3, score of 4, range 5-8
The list would not be sorted and the "scores" could be any value
I could loop through the whole list and check if the number is say 2-4 and so on through the list, or do a binary search on initially the lower range... but I think there should be some way I can just take the random number a calculate which item it represents...