Exemplo n.º 1
0
        public void Day5_PartII_Samples(long[] program, long[] input, long[] expected)
        {
            var interpreter = new IntComp(program, input);
            var actual      = interpreter.Run();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void Day9_PartI_16DigitNumber()
        {
            var quine       = new long[] { 1102, 34915192, 34915192, 7, 4, 7, 99, 0 };
            var interpreter = new IntComp(quine, Enumerable.Empty <long>());
            var output      = interpreter.Run().ToList();

            Assert.Equal(16, output[0].ToString().Length);
        }
Exemplo n.º 3
0
        public void Day9_PartI_Quine()
        {
            var quine       = new long[] { 109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99 };
            var interpreter = new IntComp(quine, Enumerable.Empty <long>());
            var output      = interpreter.Run().ToList();

            Assert.Equal(quine, output);
        }
Exemplo n.º 4
0
        public void Day5_IO_Write_Samples()
        {
            var program     = new long[] { 4, 2, 99 };
            var interpreter = new IntComp(program, Enumerable.Empty <long>());
            var output      = interpreter.Run();

            Assert.Equal(new long[] { 99 }, output);
        }
Exemplo n.º 5
0
        public void Day9_PartI_OutOfInitialMemory()
        {
            var quine       = new long[] { 1001, 1, 0, 1000, 04, 1000, 99 };
            var interpreter = new IntComp(quine, Enumerable.Empty <long>());
            var output      = interpreter.Run();

            Assert.Equal(1, output.First());
        }
Exemplo n.º 6
0
        public void Day9_PartI_LargeNumber()
        {
            var quine       = new long[] { 104, 1125899906842624, 99 };
            var interpreter = new IntComp(quine, Enumerable.Empty <long>());
            var output      = interpreter.Run();

            Assert.Equal(1125899906842624, output.First());
        }
Exemplo n.º 7
0
        public void Day5_Indirect_Samples(long[] initial, long[] final)
        {
            var interpreter = new IntComp(initial, Enumerable.Empty <long>());

            _ = interpreter.Run().ToList();
            var memory = interpreter.GetMemory(initial.Length);

            Assert.Equal(final, memory);
        }
Exemplo n.º 8
0
        public void Day5_IO_Read_Samples()
        {
            var program     = new long[] { 3, 1, 99 };
            var interpreter = new IntComp(program, new long[] { 42 });

            _ = interpreter.Run().ToList();
            var memory = interpreter.GetMemory(program.Length);

            Assert.Equal(new long[] { 3, 42, 99 }, memory);
        }