コード例 #1
0
        public void ExecuteProgram_NoudVerb_AddMultiply()
        {
            // Arrange
            var program = "1,9,10,3,2,3,11,0,99,30,40,50";
            var result  = "3500,9,10,70,2,3,11,0,99,30,40,50";
            var intcode = new Intcode.Interpreter(program);

            // Act
            intcode.ExecuteProgram_NounVerb(9, 10);

            // Assert
            Assert.AreEqual(result, intcode.GenerateProgramString());
        }
コード例 #2
0
        // == == == == == Puzzle 2 == == == == ==
        public static string Puzzle2(string input)
        {
            var intcode = new Intcode.Interpreter(input);

            for (int noun = 0; noun < 100; noun++)
            {
                for (int verb = 0; verb < 100; verb++)
                {
                    if (intcode.ExecuteProgram_NounVerb(noun, verb) == 19690720)
                    {
                        return((100 * noun + verb).ToString());
                    }
                }
            }

            throw new Exception("Could not find noun and verb that produced 19690720");
        }
コード例 #3
0
        // == == == == == Puzzle 1 == == == == ==
        public static string Puzzle1(string input)
        {
            var intcode = new Intcode.Interpreter(input);

            return(intcode.ExecuteProgram_NounVerb(12, 2, resetMemory: false).ToString());
        }