Program.cs 752 B

1234567891011121314151617181920212223242526272829
  1. using Day5;
  2. using Range = Day5.Range;
  3. if (args.Length < 1)
  4. {
  5. Console.WriteLine("Requires 1 args: inputFileName");
  6. return -1;
  7. }
  8. var inputFile = args[0];
  9. var parser = new MapParser();
  10. var almanac = parser.Parse(inputFile);
  11. var mapped = almanac.Map(almanac.Seeds, "seed", "location");
  12. Console.WriteLine($"Locations: {string.Join(", ", mapped)}");
  13. Console.WriteLine($"Min: {mapped.Min()}");
  14. var ranges = almanac.Seeds
  15. .Where((_, index) => index % 2 == 0)
  16. .Select((start, index) => new Range(start, almanac.Seeds[2 * index + 1]))
  17. .ToList();
  18. var locationRanges = almanac.Map(ranges, "seed", "location");
  19. Console.WriteLine();
  20. Console.WriteLine($"Min: {locationRanges.Min(x => x.Start)}");
  21. return 0;