Example #1
0
        public string FindStartingPair(int product)
        {
            ICC icc  = new ICC(Input);
            int verb = 1;
            int max  = 99;

            int  noun  = max / 2;
            bool found = false;

            for (int i = 0; i <= 99; i++)
            {
                for (int j = 0; j <= 99; j++)
                {
                    icc.ResetMemory();
                    icc.SetArrayValues(1, i);
                    icc.SetArrayValues(2, j);
                    icc.IntCodeComputer();
                    var output = icc.opCodeSequence[0];
                    if (output == product)
                    {
                        verb  = j;
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    noun = i;
                    break;
                }
            }
            return($"{100 * noun + verb}");
        }
Example #2
0
        protected override string SolvePartOne()
        {
            ICC icc = new ICC(Input);

            icc.SetArrayValues(1, 12);
            icc.SetArrayValues(2, 2);
            icc.IntCodeComputer();
            return(icc.opCodeSequence[0].ToString());
        }