This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a fairly ugly solution; in a hurry and didn't spend much time on it. | |
import scala.util.Random | |
case class WeightedItem[T](item: T, weight: Double) | |
val items = Seq(WeightedItem("Red", 1d/6), WeightedItem("Blue", 2d/6), | |
WeightedItem("Green", 3d/6) ) | |
def weightedSelection[T]( |