Ejemplo n.º 1
0
        public void PartTwo(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var drone   = new Drone(program);

            Point point = (0, 50);

            while (true)
            {
                while (!drone.TestPoint(point))
                {
                    point += (1, 0);
                }

                var topLeft = point + (99, -99);
                if (drone.TestPoint(topLeft))
                {
                    break;
                }

                point += (0, 1);
            }


            @out.WriteLine($"Largest bounding box starts at: {point}");
            @out.WriteLine($"Result of calculation is: {(point.X * 10_000) + (point.Y - 99)}");
        }
Ejemplo n.º 2
0
        public void PartTwo(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var network = new Network(50, program, @out);

            var result = network.SimulateWithNat();

            @out.WriteLine($"Packet Sent to 0 Twice: Y = {result.Y}");
        }
Ejemplo n.º 3
0
        public void PartOne(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var network = new Network(50, program, @out);

            var result = network.Simulate();

            @out.WriteLine($"Packet Sent to 255: X = {result.X}, Y = {result.Y}");
        }
Ejemplo n.º 4
0
        public void PartTwo(string input, TextWriter @out)
        {
            var memory = IntcodeParser.Parse(input);

            memory = memory.SetItem(0, 2);
            var cabnet = new Cabinet(memory);
            var score  = cabnet.Run();

            @out.WriteLine($"Final Score is: {score}");
        }
Ejemplo n.º 5
0
        public void PartOne(string input, TextWriter @out)
        {
            var memory = IntcodeParser.Parse(input);
            var cabnet = new Cabinet(memory);

            cabnet.Run();
            var wallCount = cabnet.Tiles
                            .Values
                            .Count(tt => tt == TileType.Block);

            @out.WriteLine($"Number of walls: {wallCount}");
        }
Ejemplo n.º 6
0
        public void PartOne(string input, TextWriter @out)
        {
            var map = ScaffoldingInterface.Run(IntcodeParser.Parse(input));

            PrintMap(map, @out);

            var intersections = FindIntersections(map);

            var alignment = intersections
                            .Sum(point => point.X * point.Y);

            @out.WriteLine($"Sum of alignment parameters: {alignment}");
        }
Ejemplo n.º 7
0
        public void PartTwo(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var droid   = new Droid(program);
            var map     = droid.Run();

            var source = map.First(x => x.Value == CellType.OxygenSystem).Key;

            var filled = Filler.FloodFill(map, source);
            var steps  = filled.Values.Max();

            @out.WriteLine($"Number of minutes taken to spread: {steps}");
        }
Ejemplo n.º 8
0
        public void PartOne(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var droid   = new Droid(program);
            var map     = droid.Run();

            PrintMap(map, @out);

            var func   = BuildShortestFunction(map, Point.Origin);
            var target = map.First(x => x.Value == CellType.OxygenSystem).Key;

            var path = func(target);

            @out.WriteLine($"Found path the oxygen system with length {path.Length - 1}");
        }
Ejemplo n.º 9
0
        public void PartTwo(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var map     = ScaffoldingInterface.Run(program);
            var actions = BuildPath(map);

            var(inputProgram, subsets) = CalculateSubsets(actions);

            @out.WriteLine($"Generated Path: {string.Join(",", actions)}");
            @out.WriteLine($"Generated Program: {string.Join(",", inputProgram)}");
            foreach (var subset in subsets)
            {
                @out.WriteLine($"Subset: {string.Join(",", subset)}");
            }

            var updatedProgram = program.SetItem(0, 2);
            var dust           = ScaffoldingInterface.RunWithInput(updatedProgram, inputProgram, subsets);

            @out.WriteLine($"Amount of dust collected by Robot is: {dust}");
        }
Ejemplo n.º 10
0
        public void PartOne(string input, TextWriter @out)
        {
            var program = IntcodeParser.Parse(input);
            var drone   = new Drone(program);
            var points  = new HashSet <Point>();

            const int dimensions = 50;

            for (var y = 0; y < dimensions; y++)
            {
                for (var x = 0; x < dimensions; x++)
                {
                    Point point = (x, y);
                    if (drone.TestPoint(point))
                    {
                        points.Add(point);
                    }
                }
            }

            PrintVision(points, dimensions);

            @out.WriteLine($"We have {points.Count} points where the drone is pulled");
        }
Ejemplo n.º 11
0
 public static ImmutableArray <long> Parse(this IInput input) => IntcodeParser.Parse(input.Content.AsSpan());