Exemplo n.º 1
0
        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.");
        }
Exemplo n.º 2
0
 public string CheckInputToGetAnswerPart1()
 {
     return(SeatIds.Max().ToString());
 }