예제 #1
0
        public decimal RunParalellAmplifiers(string path)
        {
            Day7InputReader day2InputReader = new Day7InputReader();
            List <decimal>  Memory          = day2InputReader.ReadArray(path, ',').ToList();

            decimal maximum = 0;

            int[] phase = new int[5] {
                0, 0, 0, 0, 0
            };
            for (int i = 56789; i <= 98765; i++)
            {
                string number = GetNumberAsString(i);
                if (!NumberContains56789(number))
                {
                    continue;
                }

                for (int j = 0; j < 5; j++)
                {
                    phase[j] = int.Parse(number[j].ToString());
                }

                decimal output = GetParalellOutput(Memory, phase);
                if (output > maximum)
                {
                    maximum = output;
                }
            }

            return(maximum);
        }
예제 #2
0
        public List <decimal> GetBoostCode(string path, int?input)
        {
            Day7InputReader day2InputReader = new Day7InputReader();
            List <decimal>  fileContent     = day2InputReader.ReadArray(path, ',').ToList();

            Amplifier amp = new Amplifier();

            amp.Memory = fileContent;
            amp.Input  = new List <decimal>();
            if (input.HasValue)
            {
                amp.Input.Add(input.Value);
            }

            amp.Output = new List <decimal>();
            while (!amp.Finished)
            {
                amp.IntCode();
            }

            return(amp.Output);
        }