예제 #1
0
        public Day10()
        {
            LoadData();
            HashPoints = new List <Point>();
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    if (_data[x, y] == '#')
                    {
                        HashPoints.Add(new Point(x, y));
                    }
                }
            }

            AnchorsWithHits = new List <AnchorPointWithHits>();

            foreach (Point anchor in HashPoints)
            {
                AnchorPointWithHits anchorPoint = new AnchorPointWithHits(anchor);

                foreach (Point target in HashPoints)
                {
                    if (anchor.IsEquivalent(target) == false)
                    {
                        anchorPoint.AddHit(new Angle(anchor, target));
                    }
                }

                AnchorsWithHits.Add(anchorPoint);
            }
        }
예제 #2
0
        public void Part2()
        {
            foreach (AnchorPointWithHits anchor in AnchorsWithHits)
            {
                anchor.CalculateVisible();
            }

            int max = AnchorsWithHits.Max(a => a.NVisible);
            AnchorPointWithHits best = AnchorsWithHits.FirstOrDefault(a => a.NVisible == max);
            Angle nth = best.BlowEmUp(200);

            int rslt = nth.Target.X * 100 + nth.Target.Y;

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