Exemplo n.º 1
0
        public string Solve(string[] input)
        {
            var seatConverter = new SeatConverter();

            var orderedSeats = input.Select(a => seatConverter.GetSeatId(a)).OrderBy(a => a).ToArray();

            for (var i = 1; i < orderedSeats.Length; i++)
            {
                if (orderedSeats[i] - orderedSeats[i - 1] > 1)
                {
                    return((orderedSeats[i] - 1).ToString());
                }
            }

            throw new ArgumentException("Array must be contiguous with one exception");
        }
Exemplo n.º 2
0
        public string Solve(string[] input)
        {
            var seatConverter = new SeatConverter();

            ulong maxSeatId = 0;

            foreach (var line in input)
            {
                var seatId = seatConverter.GetSeatId(line);
                if (seatId > maxSeatId)
                {
                    maxSeatId = seatId;
                }
            }

            return(maxSeatId.ToString());
        }