diff --git a/WhiteRabbit/PrecomputedPermutationsGenerator.cs b/WhiteRabbit/PrecomputedPermutationsGenerator.cs index f26ce24..b9467bf 100644 --- a/WhiteRabbit/PrecomputedPermutationsGenerator.cs +++ b/WhiteRabbit/PrecomputedPermutationsGenerator.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; - internal class PrecomputedPermutationsGenerator + internal static class PrecomputedPermutationsGenerator { private static PermutationsGenerator.Permutation[] Permutations1 { get; } = PermutationsGenerator.HamiltonianPermutations(1).ToArray(); @@ -17,7 +17,7 @@ public static IEnumerable HamiltonianPermutations(int n) { - switch(n) + switch (n) { case 1: return Permutations1; diff --git a/WhiteRabbit/Program.cs b/WhiteRabbit/Program.cs index a80e8db..b5b8148 100644 --- a/WhiteRabbit/Program.cs +++ b/WhiteRabbit/Program.cs @@ -31,7 +31,7 @@ { if (expectedHashesAsVectors.Contains(result.Item2)) { - Console.WriteLine("Found phrase: " + result.Item1); + Console.WriteLine($"Found phrase: {result.Item1}"); } } } diff --git a/WhiteRabbit/StringsProcessor.cs b/WhiteRabbit/StringsProcessor.cs index a585410..3cbe422 100644 --- a/WhiteRabbit/StringsProcessor.cs +++ b/WhiteRabbit/StringsProcessor.cs @@ -37,7 +37,7 @@ // converting sequences of vectors to the sequences of words... var anagramsWords = sums .Select(sum => ImmutableStack.Create(sum.Select(vector => formattedWords[vector]).ToArray())) - .SelectMany(Flatten) + .SelectMany(this.Flatten) .Select(stack => stack.ToArray()); return anagramsWords.Select(list => string.Join(" ", list)); @@ -53,7 +53,7 @@ T[] wordVariants; var newStack = phrase.Pop(out wordVariants); - return Flatten(newStack).SelectMany(remainder => wordVariants.Select(word => remainder.Push(word))); + return this.Flatten(newStack).SelectMany(remainder => wordVariants.Select(word => remainder.Push(word))); } } } diff --git a/WhiteRabbit/VectorsProcessor.cs b/WhiteRabbit/VectorsProcessor.cs index def5f2a..1514d79 100644 --- a/WhiteRabbit/VectorsProcessor.cs +++ b/WhiteRabbit/VectorsProcessor.cs @@ -32,14 +32,13 @@ private long Iterations { get; set; } = 0; - // Produces all sequences of vectors with the target sum public IEnumerable[]> GenerateSequences(IEnumerable> vectors) { - var filteredVectors = FilterVectors(vectors); + var filteredVectors = this.FilterVectors(vectors); var dictionary = ImmutableStack.Create(filteredVectors.ToArray()); - var unorderedSequences = GenerateUnorderedSequences(this.Target, ImmutableStack.Create>(), dictionary); - var allSequences = unorderedSequences.SelectMany(GeneratePermutations); + var unorderedSequences = this.GenerateUnorderedSequences(this.Target, ImmutableStack.Create>(), dictionary); + var allSequences = unorderedSequences.SelectMany(this.GeneratePermutations); return allSequences; } @@ -75,7 +74,7 @@ Vector currentVector; var nextDictionaryTail = dictionaryTail.Pop(out currentVector); - DebugState(partialSumStack, currentVector); + this.DebugState(partialSumStack, currentVector); var newRemainder = remainder - currentVector; if (newRemainder == Vector.Zero) @@ -84,7 +83,7 @@ } else if ((newRemainder & Negative) == Vector.Zero) { - foreach (var result in GenerateUnorderedSequences(newRemainder, partialSumStack.Push(currentVector), dictionaryTail)) + foreach (var result in this.GenerateUnorderedSequences(newRemainder, partialSumStack.Push(currentVector), dictionaryTail)) { yield return result; } @@ -101,7 +100,7 @@ Vector currentVector; dictionaryTail = dictionaryTail.Pop(out currentVector); - DebugState(partialSumStack, currentVector); + this.DebugState(partialSumStack, currentVector); var newRemainder = remainder - currentVector; if (newRemainder == Vector.Zero)