Ejemplo n.º 1
0
 public override string A()
 {
     long[] program = Input.Split(",").Select(long.Parse).ToArray();
     program[1] = 12;
     program[2] = 2;
     IntcodeComputer.Run(ref program);
     return(program[0].ToString());
 }
Ejemplo n.º 2
0
        public override string A()
        {
            long biggest = 0;

            foreach (int[] phases in GetPermutations(new[] { 0, 1, 2, 3, 4 }))
            {
                long input = 0;
                foreach (int phase in phases)
                {
                    input = IntcodeComputer.Run(Input, phase, input);
                }
                if (input > biggest)
                {
                    biggest = input;
                }
            }
            return(biggest.ToString());
        }
Ejemplo n.º 3
0
        public override string B()
        {
            long[] originalProgram = Input.Split(",").Select(long.Parse).ToArray();
            long   target          = 19690720;
            long   a        = 12;
            long   previous = 0;
            long   result   = 0;

            while (result < target)
            {
                previous = result;
                long[] program = (long[])originalProgram.Clone();
                program[1] = ++a;
                program[2] = 0;
                IntcodeComputer.Run(ref program);
                result = program[0];
            }
            long b = target - previous;

            return((((a - 1) * 100) + b).ToString());
        }