Exemple #1
0
        public List <int> Run()
        {
            List <int> opCodes = InitialIntCodes.ToList();

            (List <int> intCodes, _) = RunInternal(opCodes, 0);
            return(intCodes);
        }
Exemple #2
0
 public (int noun, int verb) FindNounAndVerbForOutput(int expectedOutput)
 {
     // Noun and verb can range from 00 to 99.
     // Brute force approach: iterate through both range until finding the expected value.
     for (int nounIndex = 0; nounIndex < 100; nounIndex++)
     {
         for (int verbIndex = 0; verbIndex < 100; verbIndex++)
         {
             List <int> opCodes = InitialIntCodes.ToList();
             opCodes[1]             = nounIndex;
             opCodes[2]             = verbIndex;
             (List <int> result, _) = RunInternal(opCodes, 0);
             if (result[0] == expectedOutput)
             {
                 return(nounIndex, verbIndex);
             }
         }
     }
     return(-1, -1);
 }