int[][] ForceInclude(int[][] combArrayUnfiltered, List <int> includedList) { int[][] tempArrayInclude = new int[combArrayUnfiltered.Length][]; for (int i = 0; i < combArrayUnfiltered.Length; i++) { int test = 0; foreach (int item in includedList) { if (Array.Exists(combArrayUnfiltered[i], control => control == item)) { test++; } if (test == includedList.Count) { tempArrayInclude[i] = combArrayUnfiltered[i]; } else { tempArrayInclude[i] = null; } } } return(CustomArray.ReduceArrayByPushingOutNulls(tempArrayInclude)); }
int[][] Combine() { string fileContent = FetchFileFromUrl(); int[][] wonDrawsArray = CustomArray.CropArray(CustomArray.CreateIntArrayFromString(fileContent)); List <Tuple <int, int> > tupleList = GetControlCombsLengthAndAmount(wonDrawsArray); int[] chosenNumbers = CustomArray.ParseStringArray(Regex.Split(chosenNumbersTextBox.Text, @"(?=\s)")); var combinationsSix = chosenNumbers.Combinations(6); int[][] tempCombinationsSixArrayInt = CustomArray.CreateCombinationsArray(combinationsSix, 6); for (int i = 0; i < tupleList.Count; i++) { if (IgnoreLastCheckBoxADV.IsChecked == true) { tempCombinationsSixArrayInt = CreateCombinationsArrayToBeDisplayed(chosenNumbers, tempCombinationsSixArrayInt, tupleList, i, startIteration: 1, wonDrawsArray); } else { tempCombinationsSixArrayInt = CreateCombinationsArrayToBeDisplayed(chosenNumbers, tempCombinationsSixArrayInt, tupleList, i, startIteration: 0, wonDrawsArray); } } return(tempCombinationsSixArrayInt); }
private void PartialCombinationsButton_Click(object sender, RoutedEventArgs e) { PrepareGUIforTableView(); int combFilter = GetComboBoxValue(FilterComboBox.SelectedIndex); string fileContent = FetchFileFromUrl(); inputTextBox.Text = fileContent; int[] chosenNumbers = CustomArray.ParseStringArray(Regex.Split(chosenNumbersTextBox.Text, @"(?=\s)")); // Build combinations of five, four, three numbers var combinationsFive = chosenNumbers.Combinations(combFilter); // Create control array of five int[][] tempControlArrayInt = CustomArray.CreateCombinationsArray(combinationsFive, combFilter); // Create final array of five int[][] controlDrawsArray = CustomArray.CropArray(CustomArray.CreateIntArrayFromString(fileContent)); int howManyDrawsConsider = HowManyDrawsConsider(controlDrawsArray); //Compare int[][] tempControlArray = CustomArray.CompareArrays(CustomArray.EPurpose.statistics, outerLoopArray: tempControlArrayInt, innerLoopArray: controlDrawsArray, tempControlArrayInt.Length, startIteration: 0, howManyDrawsConsider, combFilter); //Filter array int[][] finalControlArrayFiltered = CustomArray.ReduceArrayByPushingOutNulls(tempControlArray); //Create string array to be displayed via TableView string[][] partialCombArray = CustomArray.CreatePartialCombArray(finalControlArrayFiltered); //Display DataView view = new DataView(Tables.PopulateDataTable(partialCombArray, Tables.ETableType.partial, new string[] { "Combination", "Count" })); view.Sort = "Combination ASC"; dataGridView.ItemsSource = view; }
int[][] CreateCombinationsArrayToBeDisplayed(int[] chosenNumbers, int[][] tempCombArray, List <Tuple <int, int> > tupleList, int index, int startIteration, int[][] wonDrawsArray) { // Build combinations of five, four, three numbers var combinationsShort = chosenNumbers.Combinations(tupleList[index].Item1); // Create control array of five, four, three numbers int[][] tempControlArrayInt = CustomArray.CreateCombinationsArray(combinationsShort, tupleList[index].Item1); // Create temp array of draws //int[][] controlDrawsArray = CustomArray.CropArray(CustomArray.CreateIntArrayFromString(fileContent)); int[][] tempControlArray = CustomArray.CompareArrays(CustomArray.EPurpose.control, tempControlArrayInt, wonDrawsArray, tempControlArrayInt.Length, startIteration, tupleList[index].Item2, tupleList[index].Item1); //Filter array int[][] finalControlArrayFiltered = CustomArray.ReduceArrayByPushingOutNulls(tempControlArray); //Create temporary combinations array to be filtered int[][] tempCombinationsArray = CustomArray.CompareArrays(tempCombArray, finalControlArrayFiltered, tempCombArray.Length, tupleList[index].Item1); //Prepare final combinations array int[][] finalCombinationsArrayFiltered; if (EvensOddsCheckBox.IsChecked == true) { //Remove evens-only or odds-only combinations int[][] combinationsArrayWithoutEvensOnlyOrOddsOnly = CustomArray.RemoveEvensOrOddsOnlyComb(tempCombinationsArray); //Pull out nulls finalCombinationsArrayFiltered = CustomArray.ReduceArrayByPushingOutNulls(combinationsArrayWithoutEvensOnlyOrOddsOnly); } else { //Pull out nulls finalCombinationsArrayFiltered = CustomArray.ReduceArrayByPushingOutNulls(tempCombinationsArray); } return(finalCombinationsArrayFiltered); }
private void CheckCombinationButton_Click(object sender, RoutedEventArgs e) { DisplayFileContent(); string[] drawsArray = CustomArray.SeparateToLines(GetFileContentAsString()); string sequenceToCheck = ""; bool sequenceAlreadyWon = false; bool valueIsInteger = false; int maxNumber = GetMaxNumber(); GetMaxNumber(); Dictionary <TextBox, string> textBoxes = new Dictionary <TextBox, string>() { { num1TextBox, num1TextBox.Text }, { num2TextBox, num2TextBox.Text }, { num3TextBox, num3TextBox.Text }, { num4TextBox, num4TextBox.Text }, { num5TextBox, num5TextBox.Text }, { num6TextBox, num6TextBox.Text }, }; foreach (KeyValuePair <TextBox, string> pair in textBoxes) { valueIsInteger = int.TryParse(pair.Value, out int parsedNumber); if (!valueIsInteger || parsedNumber <= 0 || (parsedNumber > maxNumber && maxNumber != 0)) { const string MESSAGE = "Some entries are invalid"; const string CAPTION = "Invalid number"; var result = MessageBox.Show(MESSAGE, CAPTION, MessageBoxButton.OK); pair.Key.Focus(); break; } else if (pair.Key != num6TextBox) { sequenceToCheck += (pair.Value + "\t"); } else { sequenceToCheck += (pair.Value); } } if (valueIsInteger) { foreach (string item in drawsArray) { sequenceAlreadyWon = item.Contains(sequenceToCheck); if (sequenceAlreadyWon) { const string MESSAGE = "This sequence of numbers already won"; const string CAPTION = "Combination already won in the past"; var result = MessageBox.Show(MESSAGE, CAPTION, MessageBoxButton.OK); break; } } if (!sequenceAlreadyWon) { const string MESSAGE = "Nothing found"; const string CAPTION = "Nothing found"; var resultNothingFound = MessageBox.Show(MESSAGE, CAPTION, MessageBoxButton.OK); } } }