fork(1) download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8.  
  9.  
  10. public static void Main()
  11. {
  12. var lapTimes = new[]{"00:30", "1:50","2:00"};
  13. string[] formats = new[] { "mm:ss", "m:ss" };
  14. var laps = lapTimes.Select(s => DateTime.ParseExact(s, formats, CultureInfo.InvariantCulture,DateTimeStyles.None).TimeOfDay)
  15. .OrderBy(ts => ts)
  16. .ToList();
  17. var diffs = laps.Take(1)
  18. .Concat(laps.Skip(1).Select((ts, i) => ts - laps[i]))
  19. .ToList();
  20. foreach(TimeSpan ts in diffs)
  21. Console.WriteLine(ts.ToString());
  22. }
  23. }
Success #stdin #stdout 0.09s 35104KB
stdin
Standard input is empty
stdout
00:00:30
00:01:20
00:00:10