Code cleanup

rx
Inga 🏳‍🌈 8 years ago
parent eb47f42d74
commit ebcb6b0b54
  1. 2
      WhiteRabbit/VectorsConverter.cs
  2. 5
      WhiteRabbit/VectorsProcessor.cs

@ -9,7 +9,7 @@
public VectorsConverter(string sourceString)
{
var rawNumberOfOccurrences = sourceString.GroupBy(ch => ch).ToDictionary(group => group.Key, group => group.Count());
this.IntToChar = rawNumberOfOccurrences.OrderBy(kvp => kvp.Value).ThenBy(kvp => kvp.Key).Select(kvp => kvp.Key).ToArray();
this.IntToChar = rawNumberOfOccurrences.OrderBy(kvp => kvp.Key).Select(kvp => kvp.Key).ToArray();
this.CharToInt = Enumerable.Range(0, this.IntToChar.Length).ToDictionary(i => this.IntToChar[i], i => i);
}

@ -35,7 +35,6 @@
public IEnumerable<Vector<byte>[]> GenerateSums(IEnumerable<Vector<byte>> vectors)
{
var filteredVectors = FilterVectors(vectors);
var dictionary = ImmutableStack.Create(filteredVectors.ToArray());
var orderedSums = GenerateOrderedSums(this.Target, ImmutableStack.Create<Vector<byte>>(), dictionary);
var allSums = orderedSums.SelectMany(GeneratePermutations);
@ -46,9 +45,7 @@
private IEnumerable<Vector<byte>> FilterVectors(IEnumerable<Vector<byte>> vectors)
{
return vectors
.Where(vector => ((this.Target - vector) & Negative) == Vector<byte>.Zero)
//.OrderByDescending(vector => this.GetWeight(vector)) //so that letters that are more rare will come first
.ToList();
.Where(vector => ((this.Target - vector) & Negative) == Vector<byte>.Zero);
}
[Conditional("DEBUG")]

Loading…
Cancel
Save