Example #1
0
    public (string Part1, string Part2) Solve(string input)
    {
        var lines = input.Split('\n');

        for (var i = 0; i < 14; i++)
        {
            a[i] = ParseNumber(lines[4 + 18 * i]);
            b[i] = ParseNumber(lines[5 + 18 * i]);
            c[i] = ParseNumber(lines[15 + 18 * i]);
        }

        var part1 = Solve(true);
        var part2 = Solve(false);

#if DEBUG
        System.Diagnostics.Debug.Assert(ArithmeticLogicUnit.FromLong(lines, part1).Registers[3] == 0);
        System.Diagnostics.Debug.Assert(ArithmeticLogicUnit.FromLong(lines, part2).Registers[3] == 0);
        System.Diagnostics.Debug.Assert(ArithmeticLogicUnit.FromLong(lines, part1 + 1).Registers[3] != 0);
        System.Diagnostics.Debug.Assert(ArithmeticLogicUnit.FromLong(lines, part2 - 1).Registers[3] != 0);
#endif

        return(part1.ToString(), part2.ToString());
    }