Esempio n. 1
0
        public void Solve1()
        {
            var input = File.ReadAllText("C:\\Code\\aoc2018\\aoc2018\\Data\\input17.txt");

            var(scan, minY) = Day17.Parse(input.Trim());
            var result = new Day17().Pour(scan);

            var(count1, count2) = Day17.CountWater(result, minY);
            _output.WriteLine(count1.ToString());
            _output.WriteLine(count2.ToString());
        }
Esempio n. 2
0
        public void Test()
        {
            var(scan, minY) = Day17.Parse(Input.Trim());
            var wateredScan = new Day17().Pour(scan);

            var(count1, _) = Day17.CountWater(scan, minY);
            var wateredMap = Day17.Print(wateredScan);

            Assert.Equal(Expected.Trim(), wateredMap.Trim());
            Assert.Equal(Count, count1);
        }
Esempio n. 3
0
        public void TestSpecialCases(string map, string expected, int expectedCount)
        {
            var lines = map.Trim().Split("\r\n");
            var scan  = new char[lines.Length, lines[0].Length];

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];
                for (var j = 0; j < line.Length; j++)
                {
                    scan[i, j] = line[j];
                }
            }

            var wateredScan = new Day17().Pour(scan);
            var wateredMap  = Day17.Print(wateredScan);

            var(count, _) = Day17.CountWater(wateredScan, 3);

            Assert.Equal(expected.Trim(), wateredMap.Trim());
            Assert.Equal(expectedCount, count);
        }