/// <summary> /// Combine a word starting and ending from an specific /// combination /// </summary> /// <param name="number">The combination start number</param> /// <param name="endNumber">The combination end number</param> private Word[] Combine(IntegerNumber number, int[] frame) { List <Word> listOfWords = new List <Word>(); Word w; Boolean HasRepetition; byte[] indexes; int countCombine = frame[0], countPermutation = frame[2]; do { indexes = number.Digits.ToArray(); w = new Word(indexes, this.Characters); HasRepetition = w.CheckRepetition(indexes); if (!HasRepetition) { w.GetMeaning(); if (w.HasMeaning) { listOfWords.Add(w); } countCombine++; } countPermutation++; number.Next(); } while (countCombine < frame[1] && countPermutation <= frame[3]); return(listOfWords.ToArray()); }
/// <summary> /// Check if the word has repeated indexes /// </summary> /// <param name="indexes">The array of indexes</param> /// <returns>True if the word has repeated indexes</returns> public bool CheckRepetition(byte[] indexes) { int i, j; byte baseNum = (byte)this.Value.ToString().Length; IntegerNumber num = new IntegerNumber(baseNum); num.Digits.Add(0); Boolean flag = false; for (int k = 0; k < baseNum * baseNum; k++) { i = num.Digits[0]; j = num.Digits[1]; if (i != j) { flag = flag || (indexes[i] == indexes[j]); if (flag) { break; } } num.Next(); } return(flag); }