fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var txt = @"John Doe 000115
  10. Wilson Chan 000386
  11. Tye Owens 000589
  12. James Peter 000211
  13. Carl Spade 000445
  14. Sally Doe 000213";
  15. var splits = txt.Split('\n')
  16. .Select(m => new KeyValuePair<string,string>(m.Substring(15,2), m))
  17. .GroupBy(z => z.Key)
  18. .Where(y => y.Count() > 1);
  19. foreach (var x in splits)
  20. {
  21. Console.WriteLine("--- {0} ---", x.Key);
  22. foreach (var y in x)
  23. Console.WriteLine(y.Value);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.02s 131776KB
stdin
Standard input is empty
stdout
--- 21 ---
James Peter 000211
Sally Doe   000213