Ejemplo n.º 1
0
Archivo: Aoc13.cs Proyecto: storm84/AOC
        public override string PartA(string[] inputs)
        {
            var program  = inputs[0].Split(',').Select(long.Parse).ToArray();
            var computer = new IntecodeComputer(program);
            Dictionary <Point, int> screen = new Dictionary <Point, int>();

            computer.Compute();
            while (computer.OutputQueue.Any())
            {
                if (computer.OutputQueue.Count < 3)
                {
                    throw new System.Exception("Invalid queue count");
                }
                var p    = new Point((int)computer.OutputQueue.Dequeue(), (int)computer.OutputQueue.Dequeue());
                int tile = (int)computer.OutputQueue.Dequeue();
                if (screen.ContainsKey(p))
                {
                    screen[p] = tile;
                }
                else
                {
                    screen.Add(p, tile);
                }
            }
            return(screen.Values.Where(x => x == 2).Count().ToString());
        }
Ejemplo n.º 2
0
        public override string PartA(string[] inputs)
        {
            var program  = inputs[0].Split(',').Select(long.Parse).ToArray();
            var computer = new IntecodeComputer(program);
            //computer.OutputToConsole = true;
            PaintingRobot rob = new PaintingRobot(computer);

            rob.Run(0);
            return(rob.PaintedPanelCount.ToString());
        }
Ejemplo n.º 3
0
        public override string PartB(string[] inputs)
        {
            var program  = inputs[0].Split(',').Select(long.Parse).ToArray();
            var computer = new IntecodeComputer(program);
            //computer.OutputToConsole = true;
            PaintingRobot rob = new PaintingRobot(computer);

            rob.Run(1);
            rob.Print();
            return("done!");
        }
Ejemplo n.º 4
0
 public PaintingRobot(IntecodeComputer icc)
 {
     intecodeComputer = icc;
 }