Ejemplo n.º 1
0
        public string RunPart1(IEnumerable <string> testData)
        {
            var commands = testData.ToList();
            var program  = new DuetProgram();

            while (!program.Terminated)
            {
                program.RunNextCommand(commands);
            }

            return(program.CommandsCount["mul"].ToString());
        }
Ejemplo n.º 2
0
        public string RunPart2(IEnumerable <string> testData)
        {
            var commands = testData.ToList();
            var a        = new DuetProgram(new Dictionary <char, long> {
                { 'p', 0 }
            });
            var b = new DuetProgram(new Dictionary <char, long> {
                { 'p', 1 }
            });

            while (!a.Terminated && !b.Terminated)
            {
                a.RunNextCommand(commands, b);
                b.RunNextCommand(commands, a);
            }

            return(b.SentCount.ToString());
        }