src/anagramsolver/services/TableHelper.cs
/// <summary>
/// Convert a word to an array (called row) telling how many of each letter is in the word
/// </summary>
/// <param name="tableHeaderOfAnagramSorted">Anagram Distinct and Sorted e.g. ailnoprstuwy</param>
/// <param name="col0">Index to ListFilter1</param>
/// <param name="col1">Length of word</param>
/// <param name="col2">A bit telling if the word is a subset of the anagram</param>
/// <param name="word">A word to encode e.g. poultryoutwitsants</param>
/// <returns>An array including number of each letter in a word e.g. 000111121124211</returns>
Convert a word to an array (called row) telling how many of each letter is in the word
Convert a word to an array ( called row ) telling how many of each letter is in the word
public int[] FillRowFromWord(IEnumerable<char> tableHeaderOfAnagramSorted, int col0, int col1, int col2, string word)
        {
            var row = new int[] { col0, col1, col2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            var lookupByChar = word.ToLookup(c => c);
            int j = 3; 
            foreach (var letter in tableHeaderOfAnagramSorted)
            {
                row[j] = lookupByChar[letter].Count();
                j++;
            }
            return row;
        }
public int [ ] FillRowFromWord ( IEnumerable < char > tableHeaderOfAnagramSorted , int col0 , int col1 , int col2 , string word ) { var row = new int [ ] { col0 , col1 , col2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; var lookupByChar = word . ToLookup ( c => c ) ; int j = 3 ; foreach ( var letter in tableHeaderOfAnagramSorted ) { row [ j ] = lookupByChar [ letter ] . Count ( ) ; j ++ ; } return row ; }
Convert a word to an array (called row) telling how many of each letter is in the word
Convert a word to an array ( called row ) telling how many of each letter is in the word
// Prefill letter counts with 0's // https://stackoverflow.com/questions/1403493/what-is-the-point-of-lookuptkey-telement // Loop letters in "table header" (ailnoprstuwy) and count number of letters of each in current row/word // Col3 - first col having count of numbers
An array including number of each letter in a word e.g.
An array including number of each letter in a word e . g .
tableHeaderOfAnagramSorted
IEnumerable<char>
Anagram Distinct and Sorted e.g. ailnoprstuwy
Anagram Distinct and Sorted e . g . ailnoprstuwy
col0
int
Index to ListFilter1
Index to ListFilter1
col1
int
Length of word
Length of word
col2
int
A bit telling if the word is a subset of the anagram
A bit telling if the word is a subset of the anagram
word
string
A word to encode e.g. poultryoutwitsants
A word to encode e . g . poultryoutwitsants