Ejemplo n.º 1
0
        public int Solution(string input)
        {
            string[] boardingPasses = boardingPassesRepository.GetBoardingPasses(input);
            int[]    seatsIds       = seats.GetSeatsIds(boardingPasses);

            int highestSeatId = seatsIds.Max();

            return(highestSeatId);
        }
Ejemplo n.º 2
0
        public int Solution(string input)
        {
            string[] boardingPasses = boardingPassesRepository.GetBoardingPasses(input);
            int[]    seatsIds       = seats.GetSeatsIds(boardingPasses);

            int highestSeatId = seatsIds.Max();
            int lowestSeatId  = seatsIds.Min();

            int seatId = highestSeatId;

            for (int i = lowestSeatId + 1; i < highestSeatId; i++)
            {
                // Seat is between the seats with IDs +1 and -1 from yours
                if (!seatsIds.Contains(i) && seatsIds.Contains(i - 1) && seatsIds.Contains(i + 1))
                {
                    seatId = i;
                    break;
                }
            }

            return(seatId);
        }