| 1234567891011121314151617181920212223242526272829 |
- using Day5;
- using Range = Day5.Range;
- if (args.Length < 1)
- {
- Console.WriteLine("Requires 1 args: inputFileName");
- return -1;
- }
- var inputFile = args[0];
- var parser = new MapParser();
- var almanac = parser.Parse(inputFile);
- var mapped = almanac.Map(almanac.Seeds, "seed", "location");
- Console.WriteLine($"Locations: {string.Join(", ", mapped)}");
- Console.WriteLine($"Min: {mapped.Min()}");
- var ranges = almanac.Seeds
- .Where((_, index) => index % 2 == 0)
- .Select((start, index) => new Range(start, almanac.Seeds[2 * index + 1]))
- .ToList();
- var locationRanges = almanac.Map(ranges, "seed", "location");
- Console.WriteLine();
- Console.WriteLine($"Min: {locationRanges.Min(x => x.Start)}");
- return 0;
|