Ejemplo n.º 1
0
        public void AnswerA()
        {
            var assemBunny = new AssemBunny();

            assemBunny.ExecuteInstructions(File.ReadAllLines("Day12_input.txt").ToList());
            Assert.AreEqual(318083, assemBunny.Registers['a']);
        }
Ejemplo n.º 2
0
        public void AnswerB()
        {
            var assemBunny = new AssemBunny();

            assemBunny.Registers['a'] = 12;
            assemBunny.ExecuteInstructions(File.ReadAllLines("Day23_input.txt").ToList());
            Assert.AreEqual(479008320, assemBunny.Registers['a']);
        }
Ejemplo n.º 3
0
        public string GetAnswerA(bool animate = false)
        {
            var computer = new AssemBunny();

            computer.ExecuteInstructions(File.ReadAllLines("Day12_input.txt").ToList());

            return("" + computer.Registers['a']);
        }
Ejemplo n.º 4
0
        public string GetAnswerB(bool animate = false)
        {
            var assemBunny = new AssemBunny();

            assemBunny.Registers['a'] = 12;
            assemBunny.ExecuteInstructions(File.ReadAllLines("Day23_input.txt").ToList());

            return("" + assemBunny.Registers['a']);
        }
Ejemplo n.º 5
0
        public void ExampleA1()
        {
            var assemBunny   = new AssemBunny();
            var instructions = new List <string>
            {
                "cpy 41 a",
                "inc a",
                "inc a",
                "dec a",
                "jnz a 2",
                "dec a"
            };

            assemBunny.ExecuteInstructions(instructions);
            Assert.AreEqual(42, assemBunny.Registers['a']);
        }
Ejemplo n.º 6
0
        public string GetAnswerA(bool animate = false)
        {
            var assemBunny = new AssemBunny();
            var lines      = File.ReadAllLines("Day25_input.txt").ToList();

            for (var i = 0; i < int.MaxValue; i++)
            {
                assemBunny.Reset();
                assemBunny.Registers['a'] = i;
                assemBunny.ExecuteInstructions(lines);
                if (assemBunny.OutputCounter >= AssemBunny.MaxOutputLength)
                {
                    return(i.ToString());
                }
            }

            return("");
        }