Exemple #1
0
        public long RunSeries(AmplifierConfigs config)
        {
            long lastOutput = 0;

            if (config == AmplifierConfigs.Series)
            {
                foreach (var amplifier in AmplifierSeries)
                {
                    amplifier.Input    = lastOutput;
                    amplifier.Computer = new IntcodeComputer(AvailablePrograms.Amplification, amplifier.Phase, amplifier.Input);
                    amplifier.Computer.Process();
                    lastOutput = amplifier.Computer.Outputs[amplifier.Computer.Outputs.Count - 1];
                }
            }
            return(lastOutput);
        }
Exemple #2
0
 public AmplificationCircuit(AmplifierConfigs config, int[] settings)
 {
     if (config == AmplifierConfigs.Series)
     {
         foreach (var setting in settings)
         {
             Amplifier amplifier = new Amplifier(setting);
             AmplifierSeries.Add(amplifier);
         }
     }
     else if (config == AmplifierConfigs.CircularList)
     {
         foreach (var setting in settings)
         {
             Amplifier amplifier = new Amplifier(setting);
             AmplifierCircuit.AddLast(new LinkedListNode <Amplifier>(amplifier));
         }
     }
 }