Пример #1
0
        public static void ExecuteStarOne(string fileLocation = "PuzzleInput/Day2.txt")
        {
            string line = File.ReadAllText(fileLocation);

            Logger.LogMessage(LogLevel.INFO, line);

            IntCode intCode = new IntCode(Array.ConvertAll(line.Split(','), int.Parse), 12, 2);

            intCode.EvaluateCodes();

            Logger.LogMessage(LogLevel.ANSWER, "2A: Value At Position 0: " + intCode.Memory[0].ToString());
        }
Пример #2
0
        public static void ExecuteStarTwo(string fileLocation = "PuzzleInput/Day2.txt")
        {
            string line = File.ReadAllText(fileLocation);

            bool outputFound = false;

            for (int currentNoun = 0; (currentNoun <= 99 && !outputFound); currentNoun++)
            {
                for (int currentVerb = 0; currentVerb <= 99 && !outputFound; currentVerb++)
                {
                    IntCode intCode = new IntCode(Array.ConvertAll(line.Split(','), int.Parse), currentNoun, currentVerb);
                    intCode.EvaluateCodes();

                    if (intCode.Memory[0] == 19690720)
                    {
                        Logger.LogMessage(LogLevel.ANSWER, "2B: Noun: " + currentNoun + "\t Verb: " + currentVerb + "\t Answer: " + (100 * currentNoun + currentVerb));
                    }
                }
            }
        }