Example #1
0
        public void RunTest()
        {
            icp2 = new IntCodeProcessor2(test1)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), -1);

            icp2 = new IntCodeProcessor2(test2)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), 1);

            icp2 = new IntCodeProcessor2(test3)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), 109);

            icp2 = new IntCodeProcessor2(test4)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), 204);

            icp2 = new IntCodeProcessor2(test5)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), 204);

            icp2 = new IntCodeProcessor2(test6)
            {
                Debug = false
            };
            // icp2.Run();
            Assert.AreEqual(icp2.RunWithOutput(), 204);

            icp2 = new IntCodeProcessor2(test7)
            {
                Debug = false, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 32 }
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test8)
            {
                Debug = false, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 32 }
            };
            icp2.Run();

            // Assert.Fail();
        }
Example #2
0
        public long Answer(params long[] arguments)
        {
            runProgram();
            IntCodeProcessor2 icp2 = new IntCodeProcessor2(program2);

            icp2.Run();

            Console.WriteLine($"New processor: {icp2.Memory[0]}");
            Console.WriteLine($"Old processor: {program[0]}");

            return(program[0]);
        }
Example #3
0
        public long Answer(params long[] arguments)
        {
            try
            {
                IntCodeProcessor2 icp2 = new IntCodeProcessor2(programLong);

                icp2.Run();
                Console.WriteLine($"New output {icp2.Memory[0]}");

                runProgram();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(0);
        }
Example #4
0
        private long[] test8 = { 109, 1, 203, 2, 204, 2, 99 };     // outputs the input

        public long Answer(params long[] arguments)
        {
            //Console.WriteLine(processor.RunCode(code.ToList(), new int[] {}));
            IntCodeProcessor2 icp2;

            //Day 1
            icp2 = new IntCodeProcessor2(program)
            {
                Debug = false, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 1 }
            };

            icp2.Run();

            // Day 2
            icp2 = new IntCodeProcessor2(program)
            {
                Debug = false, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 2 }
            };

            icp2.Run();

            // Tests
            bool debug = false;

            icp2 = new IntCodeProcessor2(test1)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test2)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test3)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test4)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test5)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test6)
            {
                Debug = debug
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test7)
            {
                Debug = debug, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 32 }
            };
            icp2.Run();

            icp2 = new IntCodeProcessor2(test8)
            {
                Debug = debug, InputModeSetting = IntCodeProcessor2.InputMode.Set, InputNumbers = { 32 }
            };
            icp2.Run();


            return(0);
        }