Created
December 5, 2020 08:23
-
-
Save piksel/6e84056a60d234845f9cd09c9ca33d71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System.Collections.Immutable; | |
using System.Linq; | |
using static System.Linq.Enumerable; | |
using static ConLib.PrettyConsole; | |
var seats = new bool[0b1111111111]; | |
foreach (var line in File.ReadLines("input.txt")) | |
seats[line.Select(s => "BR".Contains(s) ? 1 : 0).Aggregate(0, (a, b) => b | a << 1)] = true; | |
var taken = seats.Select((s, i) => s ? i : -1).Where(i => i >= 0).ToImmutableArray(); | |
var max = taken.Max(); | |
var min = taken.Min(); | |
var seat = Range(min, max - min).Single(s => !taken.Contains(s)); | |
WriteLine($"Silver: {max}"); | |
WriteLine($"Gold: {seat}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment