コード例 #1
0
ファイル: AdventOfCodeTests.cs プロジェクト: hervala/AoC2019
        public async Task Day08_Part2_Test()
        {
            var result = await fixture.Client.GetAsync("/2019/day/8/input");

            result.EnsureSuccessStatusCode();
            var input = await result.Content.ReadAsStringAsync();

            var imageLayers = Day08.DecodeImageData(input, imageWidth: 25, imageHeight: 6);
            var image       = Day08.MergeLayers(imageLayers);

            for (int j = 0; j < image.GetLength(1); j++)
            {
                for (int i = 0; i < image.GetLength(0); i++)
                {
                    if (image[i, j] == Day08.Black)
                    {
                        Debug.Write("@");
                    }
                    else
                    {
                        Debug.Write(".");
                    }
                }
                Debug.Write(Environment.NewLine);
            }

            // output:
            //.@@.@@..@@.@@.@....@@..@@
            //.@.@@.@@.@.@@.@@@@.@.@@.@
            //..@@@.@@.@.@@.@@@.@@.@@.@
            //.@.@@....@.@@.@@.@@@....@
            //.@.@@.@@.@.@@.@.@@@@.@@.@
            //.@@.@.@@.@@..@@....@.@@.@

            Assert.Equal("KAUZA", "KAUZA");

            // lets make bmp
            Day08.DrawImage(image, invertColors: true).Save("biosPassword.gif", System.Drawing.Imaging.ImageFormat.Gif);
        }