/// <summary> /// Calculates minimum number of picks to match x numbers. /// Also works out average/chances of other combinations. /// </summary> /// <param name="pool"></param> /// <param name="pickRules"></param> /// <param name="matches"></param> /// <returns></returns> public static double RequiredPicksToWin(Pool pool, PickRules pickRules, int matches) { int n = pool.Numbers.Count(); int k = pickRules.Quantity; int b = matches; // (k/b)! * ((n-k)/(k-b)) // ¬¬¬¬¬¬¬¬ // (n - k)! var numerator = SpecialFunctions.Factorial(n); var denominator = SpecialFunctions.Factorial(n - k); result = numerator / denominator; throw new NotImplementedException(); }
/// <summary> /// Create a pool of numbers; start and end are inclusive. /// e.g. 1-10 would have start = 1, end = 10 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> public static Pool CreatePool(int start, int end) { // Validate inputs if(start < 1) throw new ArgumentException("Canno CreatePool with start less than 1."); if(end < 1 ) throw new ArgumentException("Canno CreatePool with end less than 1."); if(start > end) throw new ArgumentException("Canno CreatePool with start greater than end."); List<int> numbers = new List<int>(); for(int i=start; i<=end; i++) { numbers.Add(i); } var pool = new Pool(); pool.Numbers = numbers; return pool; }
/// <summary> /// Create all the possible selections for the pool and pick rules. /// </summary> /// <param name="pool"></param> /// <param name="pickRules"></param> /// <returns></returns> public static List<Selection> CreateAllSelections(Pool pool, PickRules pickRules) { // Validat the input if (pool == null) throw new ArgumentNullException("pool"); if (pickRules == null) throw new ArgumentNullException("pickRules"); // Get all possible combinations based on the pickRules var allSelections = new List<Selection>(); if (!pickRules.DuplicatesAllowed && !pickRules.Ordered) { allSelections = NoDuplicatesUnorderedSelections(pool, pickRules.Quantity); } //var completed = false; //while (!completed) //{ // var selection = new Selection(); // completed = true; //} return allSelections; }
private static List<Selection> NoDuplicatesUnorderedSelections(Pool pool, int quantity) { var allSelections = new List<Selection>(); // THIS MIGHT NOT BE A GOOD IDEA..... WOULD TAKE A LARGE AMOUNT OF MEMORY // PERHAPS WRITE TO DATABASE THEN READ BACK IN CHUNKS // Calculate how many combinations there are // Create array of that size // Fill the array // Convert to list and return return allSelections; }
/// <summary> /// Create a selection from the pool using the pick rules. /// </summary> /// <param name="pool"></param> /// <param name="pickRules"></param> /// <returns></returns> public static Selection CreateSelection(Pool pool, PickRules pickRules) { // Validat the input if (pool == null) throw new ArgumentNullException("pool"); if (pickRules == null) throw new ArgumentNullException("pickRules"); var selection = new Selection(); return selection; }
/// <summary> /// The chances of matching x balls for the given selections /// </summary> /// <param name="pool"></param> /// <param name="pickRules"></param> /// <param name="selections"></param> /// <returns></returns> public static double[] ChancesOfMatching(Pool pool, PickRules pickRules, IEnumerable<Selection> selections ) { throw new NotImplementedException(); }