fork(8) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7. public static void Main(string[] a)
  8. {
  9. var groups = new [] {
  10. "010000100001",
  11. "010000100001",
  12. "010000100001",
  13. "010000100002",
  14. "010000100002",
  15. "010000100002",
  16. "010000200003",
  17. "010000200003",
  18. "020000300004",
  19. "020000300005" }
  20. .GroupBy(s => new {
  21. Subject = s.Substring(0,2),
  22. Chapter = s.Substring(2,6),
  23. Book = s.Substring(8) });
  24.  
  25. foreach (var g in groups)
  26. {
  27. Console.WriteLine("Subject {0}, Chapter {1}, Book {2}",
  28. g.Key.Subject, g.Key.Chapter, g.Key.Book);
  29. }
  30. }
  31. }
  32.  
  33.  
Success #stdin #stdout 0.02s 38120KB
stdin
Standard input is empty
stdout
Subject 01, Chapter 000010, Book 0001
Subject 01, Chapter 000010, Book 0002
Subject 01, Chapter 000020, Book 0003
Subject 02, Chapter 000030, Book 0004
Subject 02, Chapter 000030, Book 0005