Ejemplo n.º 1
0
        private static void Part2()
        {
            Stopwatch sw = Stopwatch.StartNew();

            var input = File.ReadAllText("input.txt").Split(',').Select(long.Parse).ToArray();

            input[0] = 2;
            IntcodeComputer computer = new IntcodeComputer(input);

            string s = @"L,6,R,12,L,6,R,12,L,10,L,4,L,6,L,6,R,12,L,6,R,12,L,10,L,4,L,6,L,6,R,12,L,6,L,10,L,10,L,4,L,6,R,12,L,10,L,4,L,6,L,10,L,10,L,4,L,6,L,6,R,12,L,6,L,10,L,10,L,4,L,6";

            computer.AddASCIIInput("A,A,B,A,A,B,A,C,A,B,C\n");  //errors: more than 20 characters, need to redo the patterns
            computer.AddASCIIInput("L,6,R,12\n");
            computer.AddASCIIInput("L,10,L,4,L,6\n");
            computer.AddASCIIInput("L,6,L,10,L,10,L,4\n");
            computer.AddASCIIInput("y\n");
            bool running = true;

            while (running)
            {
                running = computer.RunNext() == long.MinValue;
                if (computer.OutputQueue.Any())
                {
                    Console.Write((char)computer.OutputQueue.Dequeue());
                }
            }

            sw.Stop();
            Debug.WriteLine(sw.Elapsed);
        }