src/anagramsolver/services/LoopSetsHelper.cs
/// <summary>
/// Pseudo:
/// Create permutationsets-loop-algoritm.
/// In the loop do
/// - Foreach set (of two words)
/// -- If set 1000 has been reached print the set number and the set words
/// -- Loop permuatations (AB and BA, when words are only two)
/// --- Validate A+B against anagram
/// --- If valid then check "A B" md5 against all 3 md5 solutions
/// ---- If found then remove the md5 from the list, so there only will be two to check against
/// ----- and return the found sentense ("A B")
/// </summary>
Create permutationsets-loop-algoritm.
In the loop do
Foreach set (of two words)
If set 1000 has been reached print the set number and the set words
Loop permuatations (AB and BA, when words are only two)
Validate A+B against anagram
If valid then check "A B" md5 against all 3 md5 solutions
If found then remove the md5 from the list, so there only will be two to check against
and return the found sentense ("A B")
Create permutationsets - loop - algoritm . In the loop do Foreach set ( of two words ) If set 1000 has been reached print the set number and the set words Loop permuatations ( AB and BA when words are only two ) Validate A + B against anagram If valid then check " A B " md5 against all 3 md5 solutions If found then remove the md5 from the list so there only will be two to check against and return the found sentense ( " A B " )
public int LoopSetsOfWordsDoValidateAndCheckMd5(int numberOfJackpots, string[] remainingHashes)
        {
            this.Md5Checker.Md5Hashes = remainingHashes;
            UInt64 combinationCounter = 0; 
            UInt64 subsetCounter = 0; 
            var totalLetters = _anagramCtrl.Anagram.RawDataWithoutSpace.Length; 
            var noOfSecrets = _anagramCtrl.Md5Hashes.Length; 
            TCurrentSetOfXPos currentSetLength = Activator.CreateInstance(typeof(TCurrentSetOfXPos), new object[] { totalLetters }) as TCurrentSetOfXPos;
            while (currentSetLength.SetNextSet() && numberOfJackpots < noOfSecrets)
            {
                numberOfJackpots = LoopWordCombinationsInCurrentSet(numberOfJackpots, currentSetLength, ref combinationCounter, ref subsetCounter);
            }
            _consoleWriteLine(" Combinations: " + string.Format("{0:n0}", combinationCounter) + ". Subsets: " + string.Format("{0:n0}", subsetCounter) + ". No more sets");
            return numberOfJackpots;
        }
public int LoopSetsOfWordsDoValidateAndCheckMd5 ( int numberOfJackpots , string [ ] remainingHashes ) { this . Md5Checker . Md5Hashes = remainingHashes ; UInt64 combinationCounter = 0 ; UInt64 subsetCounter = 0 ; var totalLetters = _anagramCtrl . Anagram . RawDataWithoutSpace . Length ; var noOfSecrets = _anagramCtrl . Md5Hashes . Length ; TCurrentSetOfXPos currentSetLength = Activator . CreateInstance ( typeof ( TCurrentSetOfXPos ) , new object [ ] { totalLetters } ) as TCurrentSetOfXPos ; while ( currentSetLength . SetNextSet ( ) && numberOfJackpots < noOfSecrets ) { numberOfJackpots = LoopWordCombinationsInCurrentSet ( numberOfJackpots , currentSetLength , ref combinationCounter , ref subsetCounter ) ; } _consoleWriteLine ( " " + string . Format ( " " , combinationCounter ) + " " + string . Format ( " " , subsetCounter ) + " " ) ; return numberOfJackpots ; }
Pseudo:
Create permutationsets-loop-algoritm.
Pseudo : Create permutationsets - loop - algoritm .
// Update hashes, so there are fewer to check against, if any was found // max 18.446.744.073.709.551.615 .... yarn // count number of combinations that is also subset of anagram // In sets of two words: The program finds Combinations: 1623 having Subsets: 0 from the wordlist // In sets of three words: If the program does not check md5 if finds Combinations: 83.743.632 having Subsets: 5672 from the wordlist //18 //3 //TCurrentSetOfXPos currentSetLength = new TCurrentSetOfXPos(totalLetters); // Not possible with parameters in generics - so instead doing as below //new TCurrentSetOfXPos(totalLetters); // When Sentence Lenght (ex spaces) = 18 = totalLetters // Loop sets - [1, 17] - downto set [9, 9] when using CurrentSetOf2Pos // Loop sets - [1, 1, 16] - downto set [6, 6, 6] when using CurrentSetOf3Pos // Loop sets - [1, 1, 1, 15] - downto set [4, 4, 5, 5] when using CurrentSetOf4Pos // Loop sets - [1, 1, 1, 1, 14] - downto set [3, 3, 4, 4, 4] - 3,3,3,4,5 when using CurrentSetOf4Pos
numberOfJackpots
int
remainingHashes
string[]