예제 #1
0
        public long Part2()
        {
            var outputConsole = new OutputFixed();
            var computer      = new IntCodeComputer(new InputFixedValue(2), outputConsole);
            var result        = computer.Execute(_program);

            return(outputConsole.GetOutPut());
        }
예제 #2
0
        public static long ExecuteAmplifierControllerSoftware(long[] program, long setting, long previousOutput)
        {
            var             inputConsole  = new InputFixedList(setting, previousOutput);
            var             outputConsole = new OutputFixed();
            IntCodeComputer computer      = new IntCodeComputer(inputConsole, outputConsole);

            computer.Execute(program);
            return(outputConsole.GetOutPut());
        }
예제 #3
0
        public long Execute(int inputValue)
        {
            var input    = new InputFixedValue(inputValue);
            var output   = new OutputFixed();
            var computer = new IntCodeComputer(input, output);

            computer.Execute(_program);

            return(output.GetOutPut());
        }
예제 #4
0
        public void TestInput1Part3_OutputMiddleLargeNumber()
        {
            long[] input         = { 104, 1125899906842624, 99 };
            var    outputConsole = new OutputFixed();
            var    computer      = new IntCodeComputer(new InputFixedValue(0), outputConsole);
            var    result        = computer.Execute(input);

            var outputValue = outputConsole.GetOutPut();

            Assert.Equal(1125899906842624, outputValue);
        }
예제 #5
0
        public void TestInput1Part2_Output16DigitNumber()
        {
            long[] input         = { 1102, 34915192, 34915192, 7, 4, 7, 99, 0 };
            var    outputConsole = new OutputFixed();
            var    computer      = new IntCodeComputer(new InputFixedValue(0), outputConsole);
            var    result        = computer.Execute(input);

            var outputValue = outputConsole.GetOutPut();

            Assert.Equal(16, outputValue.ToString().Length);
        }