コード例 #1
0
        public void Part1()
        {
            InitGrid();
            // start in the middle
            IntCode intCode = new IntCode("Day11", Instructions);
            Robot   robot   = new Robot(intCode, Grid, 0);

            List <Task> tasks = new List <Task>();

            // this block doesn't like to be put in a loop - channel sync crashes
            tasks.Add(Task.Run(() => { intCode.RunIntCode(); }));
            tasks.Add(Task.Run(() => { robot.Run(); }));

            Task.WaitAll(tasks.ToArray());

            int rslt = robot.ChangeCount;

            Console.WriteLine("Part1 {0}", rslt);
        }