Exemplo n.º 1
0
        public void TestExecuteIntcode_1()
        {
            string         intCode        = "2,4,4,5,99,0";
            IntcodeProgram intcodeProgram = new IntcodeProgram(intCode);

            int result = intcodeProgram.ExecuteIntcode().position0;

            Assert.AreEqual(2, result);
        }
Exemplo n.º 2
0
        public void TestExecuteIntcode_2()
        {
            string         intCode        = "1,1,1,4,99,5,6,0,99";
            IntcodeProgram intcodeProgram = new IntcodeProgram(intCode);

            int result = intcodeProgram.ExecuteIntcode().position0;

            Assert.AreEqual(30, result);
        }
Exemplo n.º 3
0
        public void TestLargerExample()
        {
            int            input          = 7;
            string         program        = "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99";
            IntcodeProgram intcodeProgram = new IntcodeProgram(program);

            int result = intcodeProgram.ExecuteIntcode(input).outputs.Last();

            Assert.AreEqual(999, result);
        }
Exemplo n.º 4
0
        public void Test04()
        {
            int            input          = 1;
            string         program        = "3,3,1105,-1,9,1101,0,0,12,4,12,99,1";
            IntcodeProgram intcodeProgram = new IntcodeProgram(program);

            int result = intcodeProgram.ExecuteIntcode(input).outputs.Last();

            Assert.AreEqual(1, result);
        }
Exemplo n.º 5
0
        public void Test02()
        {
            int            input          = 1;
            string         program        = "3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9";
            IntcodeProgram intcodeProgram = new IntcodeProgram(program);

            int result = intcodeProgram.ExecuteIntcode(input).outputs.Last();

            Assert.AreEqual(1, result);
        }
Exemplo n.º 6
0
        public void TestPart2Solution()
        {
            int    input   = 5;
            string program = System.IO.File.ReadAllText(DataHelper.getPath("05"));

            IntcodeProgram intcodeProgram = new IntcodeProgram(program);

            int result = intcodeProgram.ExecuteIntcode(input).outputs.Last();

            Assert.AreEqual(12077198, result);
        }