Exemplo n.º 1
0
        public long Calculate(List <string> input)
        {
            var plane = new TobogganPlane(input);

            return(LinqExtension
                   .TobogganRange(3, 1, input.Count)
                   .Count((t) => plane.IsTree(t.x, t.y)));
        }
Exemplo n.º 2
0
        public long Calculate(List <string> input)
        {
            var plane  = new TobogganPlane(input);
            var slopes = new List <(int x, int y)>
            {
                (1, 1),
                (3, 1),
                (5, 1),
                (7, 1),
                (1, 2),
            };

            return(slopes
                   .Select(s => LinqExtension
                           .TobogganRange(s.x, s.y, input.Count)
                           .Count((t) => plane.IsTree(t.x, t.y)))
                   .Select(Convert.ToInt64)
                   .Aggregate((a, x) => a * x));
        }