fork(1) download
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. Random r = new Random(DateTime.Now.Millisecond);
  12. Dictionary<Char, Int32> seed = Enumerable.Range(65, 26).ToDictionary(x => (Char)x, x => r.Next(10) % 5 != 0 ? r.Next(65536) : 1);
  13. List<Char> sample = new List<Char>();
  14. foreach (KeyValuePair<Char, Int32> kvp in seed)
  15. {
  16. for (Int32 i = 0; i < kvp.Value; i++)
  17. {
  18. sample.Add(kvp.Key);
  19. }
  20. }
  21.  
  22. Stopwatch sw = new Stopwatch();
  23. sw.Start();
  24. var result = sample.GroupBy (x => x).Where(x => x.Count() == 1).Select (x => x.Key);
  25. sw.Stop();
  26.  
  27. Console.WriteLine(String.Format("{0} to go through {1} records.", sw.Elapsed, sample.Count));
  28. Console.WriteLine(String.Format("Result: {0}", String.Join(", ", result.Select(x => x.ToString()).ToArray())));
  29. }
  30. }
Success #stdin #stdout 0.35s 37688KB
stdin
Standard input is empty
stdout
00:00:00.0014143 to go through 503836 records.
Result: A, B, H, K, M, P, T, U, V, W, Y