Example #1
0
        public static long Part1(string[] input)
        {
            var soloSinger = new Duet(0, input);

            soloSinger.Run();
            return(soloSinger.SndQueue.Last());
        }
Example #2
0
        public static long Part1(string[] input)
        {
            var conflagration = new Duet(0, input);

            conflagration.Run();
            return(conflagration.NumMul);
        }
Example #3
0
        public static long Part2(string[] input)
        {
            var program0 = new Duet(0, input);
            var program1 = new Duet(1, input);

            program0.RcvQueue = program1.SndQueue;
            program1.RcvQueue = program0.SndQueue;
            while (true)
            {
                if (!program0.Run())
                {
                    break;
                }
                if (!program1.Run())
                {
                    break;
                }
                if (program0.SndQueue.Count == 0 && program1.SndQueue.Count == 0)
                {
                    break;
                }
            }
            return(program1.NumSends);
        }