/// <summary> /// Checksum = the layer that contains the fewest 0 digits. On that layer, what is the number of 1 digits multiplied by the number of 2 digits? /// </summary> public static int CheckSum(IList <int> pixels, int width, int height) { var image = new SpaceImage(pixels, width, height); var minLayer = image.Layers.OrderBy(l => l.FlatValues().Count(v => v == 0)).First(); return(minLayer.CheckSum()); }
public static string Part2() { var input = FileReader.ReadInputLines(8).First(); var image = new SpaceImage(input.ToList().Select(i => int.Parse(i.ToString())).ToList(), 25, 6); image.Print(); // This was discerned by manually interpreting the printed image return("ZYBLH"); }
public void Render() { var image = new SpaceImage("0222112222120000".ToList().Select(i => int.Parse(i.ToString())).ToList(), 2, 2); var render = image.Render(); render.PixelAt(0, 0).Should().Be(0); render.PixelAt(0, 1).Should().Be(1); render.PixelAt(1, 0).Should().Be(1); render.PixelAt(1, 1).Should().Be(0); }