public string CheckInputToGetAnswerPart2() { var allAvailableSeatIds = Enumerable.Range(0, 128).SelectMany(r => Enumerable.Range(0, 8).Select(c => BoardingPassReader.GetSeatId(r, c))); var potentialSeats = allAvailableSeatIds.Where(s => !SeatIds.Contains(s)).ToList(); foreach (var potentialSeat in potentialSeats.Where(potentialSeat => SeatIds.Contains(potentialSeat - 1) && SeatIds.Contains(potentialSeat + 1))) { return(potentialSeat.ToString()); } throw new Exception("Seat not found."); }
public string CheckInputToGetAnswerPart1() { return(SeatIds.Max().ToString()); }