private static IEnumerable <Distribution> Get2Out3() { var lookup = new Dictionary <DicePair, int>(); foreach (var a in Roll()) { foreach (var b in Roll()) { foreach (var c in Roll()) { var all = (new[] { a, b, c }).OrderByDescending(i => i).Take(2).ToArray(); var dice = new DicePair(all[0], all[1]); if (lookup.ContainsKey(dice)) { lookup[dice]++; } else { lookup[dice] = 1; } } } } foreach (var kvp in lookup) { yield return(new Distribution(kvp.Key, kvp.Value)); } }
public Distribution(DicePair dice, int frequency) { Dice = dice; Frequency = frequency; }