static void DisplayWinnigs(WinningsResult result) { int i = DefaultValues.JACKPOT_NUMBERS_COUNT; for (; i > DefaultValues.END_INDEX_OF_WINNINGS; i--) { Console.WriteLine("Count of profitable combinations for " + i + " :" + result.Winnings[i - 1]); } }
private void DisplayWinnings(WinningsResult result) { int i = DefaultValues.JACKPOT_NUMBERS_COUNT; for (; i > DefaultValues.END_INDEX_OF_WINNINGS; i--) { labelWinnings.Text += "Profitable combinations for " + i + " :" + result.Winnings[i - 1] + "\n"; } }
public WinningsResult GetWinnings() { // keeps errors and also keeps winning values WinningsResult result = new WinningsResult(); if (!IsJackpotRegistered()) { result.Errors.Push("No registered jackpot"); } if (!IsCheckTalonRegistered()) { result.Errors.Push("No registered checktalon"); } if (result.Success()) { // first, we get the count of scored numbers // sescond, we count the combinations of n = scored numbers, k = index of profitable 6,5,4,3. . // third, we count the combinations of n = unscored numbers, k = the offset of index of profitable 6,5,4,3 // fourth, we multiply the scored and unscored numbers // save // first step var scoredNumbers = this.GetScoredNumbers(); // we begin to save our winnings from the count of scored numbers // all winnings before that index are zeroes int indexOfWinnigns = scoredNumbers; int unscoredCountOfNumbers = checkTalon.Count - scoredNumbers; while (indexOfWinnigns != DefaultValues.END_INDEX_OF_WINNINGS) { // second step ulong combinationsOfScoredNumbers = Combinatoric.GetCombinationsWithNoRepetitions(scoredNumbers, indexOfWinnigns); // third step int countOfNumbersFarFromJackpot = DefaultValues.JACKPOT_NUMBERS_COUNT - indexOfWinnigns; ulong combinationsOfUnscoredNumbers = Combinatoric.GetCombinationsWithNoRepetitions(unscoredCountOfNumbers, countOfNumbersFarFromJackpot); // fourth step var profitableCombinationsForIndex = combinationsOfScoredNumbers * combinationsOfUnscoredNumbers; // save combinations for profitable combinations in an array result.Winnings[indexOfWinnigns - 1] = profitableCombinationsForIndex; indexOfWinnigns--; } } return result; }