コード例 #1
0
        public override void PartTwo(IInput input, IOutput output)
        {
            var parser       = CpuParser.BuildParser();
            var instructions = parser
                               .ParseCommands(input.Lines)
                               .ToImmutableArray();
            var program = new Program(instructions);

            var max = program.CalculateMaxMemory();

            output.WriteProperty("Max Registry value", max);
        }
コード例 #2
0
        public override void PartOne(IInput input, IOutput output)
        {
            var parser       = CpuParser.BuildParser();
            var instructions = parser
                               .ParseCommands(input.Lines)
                               .ToImmutableArray();
            var program = new Program(instructions);

            var registry = program.Run();

            output.WriteBlock(() =>
            {
                var table = new Table()
                            .AddColumn("Registry")
                            .AddColumn("Value");

                foreach (var(registry, value) in registry.OrderByDescending(r => r.Value))
                {
                    table.AddRow(registry, value.ToString());
                }

                return(table);
            });
        }