示例#1
0
        public void Day2Test(List <long> code, List <long> outCode)
        {
            var io = new IntCodeComputerIO(new List <long>());
            var intCodeComputer = new IntCodeComputerInstance(code, io, io);

            intCodeComputer.Compute();

            Assert.IsTrue(intCodeComputer.Code.SequenceEqual(outCode));
        }
示例#2
0
        public void Day5Part2Test(List <long> code, int input, int expectedOutput)
        {
            var io = new IntCodeComputerIO(new List <long>()
            {
                input
            });

            long output     = default;
            var  outputFunc = new DelegateOutput((long i) => output = i);

            var intCodeComputer = new IntCodeComputerInstance(code, io, outputFunc);

            intCodeComputer.Compute();

            Assert.IsTrue(output == expectedOutput);
        }
示例#3
0
        public void Day9Test3()
        {
            var code = new List <long>()
            {
                104, 1125899906842624, 99
            };
            var io = new IntCodeComputerIO(new List <long>());

            long output     = default;
            var  outputFunc = new DelegateOutput((long i) => output = i);

            var intCodeComputer = new IntCodeComputerInstance(code, io, outputFunc);

            intCodeComputer.ContinueAfterOutput = true;
            intCodeComputer.Compute();

            Assert.IsTrue(1125899906842624 == output);
        }
示例#4
0
        public void Day9Test2()
        {
            var code = new List <long>()
            {
                1102, 34915192, 34915192, 7, 4, 7, 99, 0
            };
            var io = new IntCodeComputerIO(new List <long>());

            long output     = default;
            var  outputFunc = new DelegateOutput((long i) => output = i);

            var intCodeComputer = new IntCodeComputerInstance(code, io, outputFunc);

            intCodeComputer.ContinueAfterOutput = true;
            intCodeComputer.Compute();

            Assert.IsTrue(16 == output.ToString().Length);
        }
示例#5
0
        public void Day9Test1()
        {
            var origCode = new List <long>()
            {
                109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99
            };
            var code = origCode.ToList();
            var io   = new IntCodeComputerIO(new List <long>());

            var output     = new List <long>();
            var outputFunc = new DelegateOutput((long i) => output.Add(i));

            var intCodeComputer = new IntCodeComputerInstance(code, io, outputFunc);

            intCodeComputer.ContinueAfterOutput = true;
            intCodeComputer.Compute();

            Assert.IsTrue(origCode.SequenceEqual(output));
        }
示例#6
0
 /// <summary>
 /// An object representing the hull paining robot
 /// </summary>
 /// <param name="code"></param>
 public HullPaintingRobot(List <long> code)
 {
     io       = new IntCodeComputerIO(new List <long>());
     _intCode = new IntCodeComputerInstance(code, io, io);
 }
示例#7
0
 /// <summary>
 /// Creates a new instance of the repair droid
 /// </summary>
 /// <param name="code"></param>
 public RepairDroid(List <long> code)
 {
     _io             = new IntCodeComputerIO(GetNextMovementCommand);
     _io.SentOutput += _io_SentOutput;
     _computer       = new IntCodeComputerInstance(code, _io, _io);
 }