![Writing a random selection algorithm that factors in age (weighted selection)](/content/images/size/w720/2018/06/multi-sided-dice.jpg)
Writing a random selection algorithm that factors in age (weighted selection)
Have you ever had a collection of items and needed to select a random one from the lot? What if you have a class with some property (i.e. 'age' or 'weight') that you want to take into account when doing the random selection? Let's see how we might approach that...