예제 #1
0
        private static void RunTest2()
        {
            var noun  = 0;
            var found = false;

            while (!found && noun <= 99)
            {
                var verb = 0;
                while (!found && verb <= 99)
                {
                    var program = new IntCodeProgram(File.ReadAllText(InputFile).Split(',').ToList()
                                                     .Select(int.Parse).ToArray())
                    {
                        Memory = { [1] = noun, [2] = verb }
                    };

                    if (program.Output == 19690720)
                    {
                        found = true;
                        Console.WriteLine($"Noun: {noun}");
                        Console.WriteLine($"Verb: {verb}");
                        Console.WriteLine($"100 * noun + verb: {100 * noun + verb}");
                    }

                    verb++;
                }

                noun++;
            }
        }
예제 #2
0
        private static void RunTest1()
        {
            // Read all the values of the Intcode program into the array
            var program =
                new IntCodeProgram(
                    File.ReadAllText(InputFile).Split(',').ToList().Select(int.Parse).ToArray())
            {
                Memory = { [1] = 12, [2] = 2 }
            };

            // Input Params

            Console.WriteLine(program.Output);
            File.WriteAllText(OutputFile1, string.Join(',', program.Memory));
        }