Fixed bugs; removed redundant code

rx
Inga 🏳‍🌈 8 years ago
parent fc113ea2b0
commit cbe7344681
  1. 3
      WhiteRabbit/Processor.cs
  2. 18
      WhiteRabbit/Program.cs

@ -47,8 +47,7 @@
.SelectMany(Flatten) .SelectMany(Flatten)
.Select(stack => stack.ToArray()); .Select(stack => stack.ToArray());
return anagramsWords.Select(list => string.Join(" ", list)); return anagramsWords.SelectMany(GeneratePermutations).Select(list => string.Join(" ", list));
//return anagramsWords.SelectMany(GeneratePermutations).Select(list => string.Join(" ", list));
} }
private IEnumerable<string> FilterWords(IEnumerable<string> words) private IEnumerable<string> FilterWords(IEnumerable<string> words)

@ -17,26 +17,18 @@
public static void Main() public static void Main()
{ {
var processor = new Processor("poultry outwits ants", 3); var processor = new Processor("poultry outwits ants", 3);
var results = new List<string>();
foreach (var phrase in processor.GeneratePhrases(ReadInput())) foreach (var phrase in processor.GeneratePhrases(ReadInput()))
{ {
var hash = GetMd5Hash(phrase); var hash = GetHash(phrase);
Console.WriteLine(GetMd5Hash(phrase) + ": " + phrase); Console.WriteLine(hash + ": " + phrase);
results.Add(phrase + ": " + hash);
}
foreach (var result in results.OrderBy(line => line))
{
Console.WriteLine(result);
} }
} }
private static string GetMd5Hash(string input) private static string GetHash(string input)
{ {
using (MD5 md5Hash = MD5.Create()) using (MD5 hasher = MD5.Create())
{ {
// Convert the input string to a byte array and compute the hash. var data = hasher.ComputeHash(Encoding.UTF8.GetBytes(input));
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
return string.Concat(data.Select(b => b.ToString("x2"))); return string.Concat(data.Select(b => b.ToString("x2")));
} }
} }

Loading…
Cancel
Save