public IEnumerable <VariableLetterGroup> UniquePermutations() { VariableLetterGroup vlg = this.RankLetters(); foreach (VariableLetterGroup v in vlg.Permutations()) { if (v.IsOrderedAccordingToLetterRanks()) { yield return(v); } } }
public IEnumerable <VariableLetterGroup> Permutations() { int letters_length = _letters.Count; for (int i = 0; i < letters_length; i++) { if (letters_length == 1) { yield return(this); } else { VariableLetterGroup res = new VariableLetterGroup(_letters[i]); VariableLetterGroup vlg_to_permute = new VariableLetterGroup(_letters); vlg_to_permute.RemoveAt(i); foreach (VariableLetterGroup vlg_permuted in vlg_to_permute.Permutations()) { yield return(res + vlg_permuted); } } } }