예제 #1
0
        private static void TAS(IntcodeComputer computer)
        {
            string tas = @"west
                           south
                           east
                           south
                           west
                           west
                           take astrolabe
                           east
                           east
                           north
                           take monolith
                           west
                           north
                           west
                           north
                           take tambourine
                           south
                           west
                           take dark matter
                           west
                           north
                           north";

            computer.AddAsciiInputBlock(tas);
        }
예제 #2
0
        private static void Part2()
        {
            Stopwatch sw = Stopwatch.StartNew();

            var             input    = File.ReadAllText("input.txt").Split(',').Select(long.Parse);
            IntcodeComputer computer = new IntcodeComputer(input)
            {
                AsciiInputMode = true
            };

            string program = @"NOT A J
                               NOT B T
                               OR T J
                               NOT C T
                               OR T J
                               AND D J
                               RUN";

            computer.AddAsciiInputBlock(program);

            computer.Run();
            while (computer.OutputQueue.Any())
            {
                long value = computer.OutputQueue.Dequeue();
                if (value > char.MaxValue || value < char.MinValue)
                {
                    Console.WriteLine($"Part 2: {value}");
                }
                else
                {
                    Console.Write((char)value);
                }
            }

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