コード例 #1
0
        public override string Solve()
        {
            var sources        = InputReader.ReadLines().Select(Source.Parse).ToList();
            var board          = new BoardFactory(sources).CreateBoard();
            var fieldGenerator = new FieldGenerator(board);

            var fields = fieldGenerator.CreateFields(sources);

            var nonInfiniteVectors = fields.SelectMany(x => x.ToList()).Where(x => !Equals(x, Vector.Conflict) && x.Source.Infinity == false);

            var nonInfiniteSourceCount = new Dictionary <Source, int>();

            foreach (var source in sources)
            {
                nonInfiniteSourceCount[source] = nonInfiniteVectors.Count(x => Equals(x.Source, source));
            }

            return(nonInfiniteSourceCount.OrderByDescending(x => x.Value).First().Value.ToString());
        }
コード例 #2
0
        public override string Solve()
        {
            var sources        = InputReader.ReadLines().Select(Source.Parse).ToList();
            var board          = new BoardFactory(sources).CreateBoard();
            var fieldGenerator = new FieldGenerator(board);

            var fields = new List <Vector[][]>();

            foreach (var source in sources)
            {
                fields.Add(fieldGenerator.CreateFields(new List <Source> {
                    source
                }));
            }

            var combinedDistanceField = new DistanceCollator().AddUpDistances(fields);

            return(combinedDistanceField.SelectMany(x => x.ToList()).Count(x => x < _limit).ToString());
        }