Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //Day1 Part 2
            var fuelCalculator = new RecursiveFuelCalculator(new SimpleFuelCalculator());
            var componentList  = new ComponentList(@"Day1/ComponentMasses.txt", fuelCalculator);

            Console.WriteLine($"Required Fuel: {componentList.FuelRequired}");

            //Day2
            var intCodeSequence = System.IO.File.ReadAllText("Day2/IntCodes.txt");
            var intCodes        = intCodeSequence
                                  .Split(",")
                                  .Select(int.Parse)
                                  .ToList();
            var intCode = new IntCode();
            var memory  = intCode.Run(intCodes);

            Console.WriteLine("- Day 2 -");
            Console.WriteLine("Part 1");
            Console.WriteLine($"Value of address0: {memory[0]}");


            //Part2
            var intCodeGoal = intCode.FindIntCodeFromGoal(intCodes, 19690720);

            Console.WriteLine("Part 2");
            Console.WriteLine($"IntCode[0]: {intCodeGoal.Memory[0]} Noun: {intCodeGoal.Noun} Verb: {intCodeGoal.Verb}");

            //Day3
            var wire1Paths = System.IO.File.ReadAllText("Day3/Wire1Path.txt");
            var wire2Paths = System.IO.File.ReadAllText("Day3/Wire2Path.txt");

            var grid = new Grid();

            grid.RunWires(wire1Paths, wire2Paths);

            Console.WriteLine("- Day3 -");
            Console.WriteLine($"Closest crossing distance from origin: {grid.DistanceOfClosestCrossing()}");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public Arcade(long[] Code)
 {
     Code[0]  = 2;
     Computer = new IntCode(Code);
     Tiles    = new List <Tile>();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // // Tests from Reddit
            // System.Console.WriteLine("Output zero");
            // int[] data = new int[] {1,0,3,3,1005,2,10,5,1,0,4,1,99};
            // foreach (int output in IntCode.Run(data, new int[]{8})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("\n");
            // System.Console.WriteLine("Countdown");
            // data = new int[] {101,-1,7,7,4,7,1105,11,0,99};
            // foreach (int output in IntCode.Run(data, new int[]{8})) System.Console.WriteLine($">> {output}");

            // Try examples to test
            // System.Console.WriteLine("input-ex-eq8");
            // int[] data = ReadCode(@"input-ex-eq8");
            // foreach (int output in IntCode.Run(data, new int[]{8})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("input-ex-eq8-im");
            // data = ReadCode(@"input-ex-eq8-im");
            // foreach (int output in IntCode.Run(data, new int[]{8})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine();
            // System.Console.WriteLine("input-ex-lt8");
            // data = ReadCode(@"input-ex-lt8");
            // foreach (int output in IntCode.Run(data, new int[]{5})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("input-ex-lt8-im");
            // data = ReadCode(@"input-ex-lt8-im");
            // foreach (int output in IntCode.Run(data, new int[]{5})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine();
            // System.Console.WriteLine("input-ex-jmp-pm");
            // data = ReadCode(@"input-ex-jmp-pm");
            // foreach (int output in IntCode.Run(data, new int[]{0})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("input-ex-jmp-im");
            // data = ReadCode(@"input-ex-jmp-im");
            // foreach (int output in IntCode.Run(data, new int[]{0})) System.Console.WriteLine($">> {output}");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine();
            // System.Console.WriteLine("input-ex-cmp8 -- 0");
            // data = ReadCode(@"input-ex-cmp8");
            // foreach (int output in IntCode.Run(data, new int[]{0})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("input-ex-cmp8 -- 8");
            // foreach (int output in IntCode.Run(data, new int[]{8})) System.Console.WriteLine($">> {output}");
            // System.Console.WriteLine("input-ex-cmp8 -- 12");
            // foreach (int output in IntCode.Run(data, new int[]{12})) System.Console.WriteLine($">> {output}");

            System.Console.WriteLine("Day 05");
            int[] data = ReadCode(@"input");

            // Part 1
            System.Console.WriteLine("\nPart 1\n================================");
            foreach (int output in IntCode.Run(data, new int[] { 1 }))
            {
                System.Console.WriteLine($"{output}");
            }

            // Part 2
            System.Console.WriteLine("\nPart 2\n================================");
            foreach (int output in IntCode.Run(data, new int[] { 5 }))
            {
                System.Console.WriteLine($"{output}");
            }
        }
Ejemplo n.º 4
0
 public Robot(long[] Code)
 {
     Computer = new IntCode(Code);
     CurrentX = CurrentY = size / 2;
 }