protected override string Part2(string[] input) { var screen = ReadScreen(input); var letters = LetterScanner.Scan(screen); return(letters); }
protected override string Part2(string[] input) { var map = PaintHull(input[0], ColorWhite); var letters = map.Render((_, val) => val == 'W' ? '#' : ' '); var identifier = LetterScanner.Scan(letters); return(identifier); }
public void CanScanAllKnownLetters() { // See https://www.reddit.com/r/adventofcode/comments/enxuuw/unusual_request_looking_for_ascii_art_letters/ var letters = new string[] { " ██ ███ ██ ███ ████ ████ ██ █ █ ███ ██ █ █ █ ██ ███ ███ ███ ███ █ █ █ █████", "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █", "█ █ ███ █ █ █ ███ ███ █ ████ █ █ ██ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", "████ █ █ █ █ █ █ █ █ ██ █ █ █ █ █ █ █ █ █ ███ ███ ██ █ █ █ █ █ ", "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", "█ █ ███ ██ ███ ████ █ ███ █ █ ███ ██ █ █ ████ ██ █ █ █ ███ █ ██ █ ████" }; var scan = LetterScanner.Scan(letters); Assert.Equal("ABCDEFGHIJKLOPRSTUYZ", scan); }
protected override string Part2(string[] input) { var layers = GetLayers(input[0]); // Render all "pixels" by looping through each layer's similar positions and // pick the first non-transparent value, turning '1' into black and '2' into blank. var rendering = Enumerable.Range(0, Size) .Select(pos => layers.Select(x => x[pos])) .Select(x => { var value = x.First(pixel => pixel != '2'); return(value == '1' ? '#' : ' '); }) .ToArray(); var image = new string(rendering); // Split rendering into <height> individual lines and scan them var lines = Enumerable.Range(0, Height) .Select(x => image.Substring(x * Width, Width)); var message = LetterScanner.Scan(lines); return(message); }