Esempio n. 1
0
        public override void PartOne(IInput input, IOutput output)
        {
            var totalMass = input
                            .AsInts()
                            .Select(CalculateFuel)
                            .Sum();

            output.WriteProperty("Total Mass", $"{totalMass:N0}");
        }
Esempio n. 2
0
        public override void PartTwo(IInput input, IOutput output)
        {
            var lines = input.AsInts();

            var items  = FindNThatSumTo(lines, 3, 2020);
            var result = items.Aggregate(1, (acc, i) => acc * i);

            output.WriteProperty("Numbers", string.Join(", ", items));
            output.WriteProperty("Result", result);
        }