Пример #1
0
        public static void Part1()
        {
            var program = Computer.Parse(Input);

            //var program = Computer.Parse("1,0,0,0,99");
            //var program = Computer.Parse("1,1,1,4,99,5,6,0,99");

            program[1] = 12;
            program[2] = 2;

            var c = new Intcode.Day2Computer();

            Console.WriteLine(c.Run(program)[0]);
        }
Пример #2
0
        public static void Part2(string[] args)
        {
            var program  = args.Select(a => Convert.ToInt64(a)).ToArray();
            var computer = new Intcode.Day2Computer();

            for (var i = 0; i < 100; i++)
            {
                for (var j = 0; j < 100; j++)
                {
                    var copy = program.Clone() as long[];
                    copy[1] = i;
                    copy[2] = j;

                    if (computer.Run(copy)[0] == 19690720)
                    {
                        Console.WriteLine((i * 100) + j);
                        return;
                    }
                }
            }

            Console.WriteLine("No solution.");
        }