public static bool IsValid(this IBoardingPass boardingPass)
        {
            if (boardingPass == null)
            {
                throw new ArgumentNullException(nameof(boardingPass));
            }

            return(IsValidSeat(boardingPass.Seat));
        }
        public static int Row(this IBoardingPass boardingPass)
        {
            if (boardingPass == null)
            {
                throw new ArgumentNullException(nameof(boardingPass));
            }

            if (boardingPass.IsValid() == false)
            {
                throw new ArgumentException(nameof(boardingPass));
            }

            return(CalculateRowPosition(boardingPass));
        }
        public static int SeatId(this IBoardingPass boardingPass)
        {
            if (boardingPass == null)
            {
                throw new ArgumentNullException(nameof(boardingPass));
            }

            if (boardingPass.IsValid() == false)
            {
                throw new ArgumentException(nameof(boardingPass));
            }

            // (row x 8) + col
            return((Row(boardingPass) * 8) + Column(boardingPass));
        }
        private static int CalculateRowPosition(IBoardingPass boardingPass)
        {
            var rowString   = RowStringFromSeat(boardingPass.Seat);
            var rowIndexMin = _rowIndexMin;
            var rowIndexMax = _rowIndexMax;

            foreach (var rowChar in rowString)
            {
                if (rowChar == 'B')
                {
                    BinarySpacePartitioning(ref rowIndexMin, ref rowIndexMax, BinarySpacePartitioningAction.Up);
                }

                if (rowChar == 'F')
                {
                    BinarySpacePartitioning(ref rowIndexMin, ref rowIndexMax, BinarySpacePartitioningAction.Down);
                }
            }

            return(rowIndexMin); // min and max should be equal at this point.
        }
        private static int CalculateColumnPosition(IBoardingPass boardingPass)
        {
            var colString   = ColStringFromSeat(boardingPass.Seat);
            var colIndexMin = _colIndexMin;
            var colIndexMax = _colIndexMax;

            foreach (var colChar in colString)
            {
                if (colChar == 'R')
                {
                    BinarySpacePartitioning(ref colIndexMin, ref colIndexMax, BinarySpacePartitioningAction.Up);
                }

                if (colChar == 'L')
                {
                    BinarySpacePartitioning(ref colIndexMin, ref colIndexMax, BinarySpacePartitioningAction.Down);
                }
            }

            return(colIndexMin); // min and max should be equal at this point.
        }