fork(1) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var data = new string []
  9. {
  10. "17-24 36-41 53-58 138-143 155",
  11. "13-16 32 49-52 66-69",
  12. "13-16 32-35 49-52 66 83 100-103"
  13. };
  14.  
  15. int[][] res = data.Select(line => line.Split().SelectMany(s => {
  16. int x;
  17.  
  18. if (int.TryParse(s, out x))
  19. return Enumerable.Repeat(x, 1);
  20.  
  21. var lr = s.Split('-');
  22. int l = int.Parse(lr[0]), r = int.Parse(lr[1]);
  23. return Enumerable.Range(l, r-l+1);
  24. }).ToArray()).ToArray();
  25.  
  26. foreach (var line in res)
  27. Console.WriteLine("{0}\n===", String.Join(" ", line));
  28. }
  29. }
Success #stdin #stdout 0.02s 131648KB
stdin
Standard input is empty
stdout
17 18 19 20 21 22 23 24 36 37 38 39 40 41 53 54 55 56 57 58 138 139 140 141 142 143 155
===
13 14 15 16 32 49 50 51 52 66 67 68 69
===
13 14 15 16 32 33 34 35 49 50 51 52 66 83 100 101 102 103
===