Пример #1
0
        public object Work1()
        {
            var array = input.Split(new[] { ',' }).Select(x => long.Parse(x)).ToArray();

            var computer = new IntCodeComp(array);

            return(computer.RunProgram(12, 2));
        }
Пример #2
0
        public object Work2()
        {
            var array    = input.Split(new[] { ',' }).Select(x => long.Parse(x)).ToArray();
            var computer = new IntCodeComp(array);

            for (int noun = 0; noun < 100; noun++)
            {
                for (int verb = 0; verb < 100; verb++)
                {
                    long result = computer.RunProgram(noun, verb);
                    if (result == output)
                    {
                        return(100 * noun + verb);
                    }
                }
            }

            throw new Exception("Failed to find the result.");
        }