Beispiel #1
0
 protected override int SolvePartTwo()
 {
     intcodeProgram.Reset();
     intcodeProgram.AddToInput(5);
     intcodeProgram.Execute();
     return(intcodeProgram.Outputs[0]);
 }
Beispiel #2
0
        protected override int SolvePartTwo()
        {
            int       output        = 0;
            const int desiredOutput = 19690720;



            int noun = 1;
            int verb = 1;

            while (output != desiredOutput && noun <= 99 && verb <= 99)
            {
                intcodeProgram.Reset();
                intcodeProgram[1] = noun;
                intcodeProgram[2] = verb;
                intcodeProgram.Execute();
                output = intcodeProgram[0];
                if (output != desiredOutput)
                {
                    if (verb == 99)
                    {
                        verb = 1;
                        noun++;
                    }
                    verb++;
                }
            }


            return((100 * noun) + verb);
        }