Ejemplo n.º 1
0
        public override void PartOne(IInput input, IOutput output)
        {
            ImmutableHashSet <Point2d> clayPoints = input.ParseClayPoints();

            var(_, yRange) = Point2d.FindSpaceOfPoints(clayPoints);

            var before = output.File("before.txt");
            var after  = output.File("after.txt");

            var scan = new Scan(clayPoints);

            scan.Write(before);
            output.AddImage("before.png", ImageWriter.Generate(scan.Map));

            scan.Flow(Scan.WaterSpring);
            scan.Write(after);
            output.AddImage("after.png", ImageWriter.Generate(scan.Map));

            var waterBlocks = scan.Map
                              .Where(i => i.Key.Y >= yRange.Min)
                              .Count(i => i.Value is CellType.FlowingWater or CellType.StillWater);

            output.WriteProperty("Number of flowing and still blocks", waterBlocks);
        }