Пример #1
0
        public static long Step1()
        {
            var input = Input;

            input[1] = 12;
            input[2] = 2;
            return(IntCodeMachine.RunUntilStopped(input).Memory[0]);
        }
Пример #2
0
        public static int Step2()
        {
            const int sentinel = 19690720;

            for (var noun = 0; noun < 100; noun++)
            {
                for (var verb = 0; verb < 100; verb++)
                {
                    var input = Input;
                    input[1] = noun;
                    input[2] = verb;
                    var result = IntCodeMachine.RunUntilStopped(input).Memory[0];
                    if (result == sentinel)
                    {
                        return(noun * 100 + verb);
                    }
                }
            }
            throw new ApplicationException();
        }