diff options
author | Ben Harris <ben@tilde.team> | 2020-12-16 17:17:35 -0500 |
---|---|---|
committer | Ben Harris <ben@tilde.team> | 2020-12-16 17:17:35 -0500 |
commit | 837527d487c7e232b36dd87c95a15b7852f2e057 (patch) | |
tree | 21ddf9a63548ccc8c802fe5f158f3e6743a8e9f1 /Day8.cs | |
parent | c66d1d6b335e6c2f6b544ae31793f318ba2b99a7 (diff) |
refactor to two-digit day names and add puzzlename
Diffstat (limited to 'Day8.cs')
-rw-r--r-- | Day8.cs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/Day8.cs b/Day8.cs deleted file mode 100644 index cdb3ef6..0000000 --- a/Day8.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using aoc2019.lib; - -namespace aoc2019 -{ - internal sealed class Day8 : Day - { - private readonly List<List<char>> photo; - - public Day8() - { - photo = Input.First().Chunk(25 * 6).Select(s => s.ToList()).ToList(); - } - - public override int DayNumber => 8; - - protected override string Part1() - { - var l = photo.OrderBy(layer => layer.Count(pixel => pixel == '0')).First(); - return $"{l.Count(p => p == '1') * l.Count(p => p == '2')}"; - } - - protected override string Part2() - { - return Enumerable.Range(0, 25 * 6) - .Select(p => Enumerable.Range(0, photo.Count) - .Select(l => photo[l][p]) - .Aggregate('2', (acc, next) => - acc != '2' ? acc : next == '0' ? ' ' : next - ) - ) - .ToDelimitedString() - .Chunk(25) - .ToDelimitedString(Environment.NewLine) - .Replace('1', 'x'); - } - } -} \ No newline at end of file |