$highest_row ) { $highest_row = $row; } else if ( $row < $lowest_row ) { $lowest_row = $row; } // $low = 0; $high = $cols_on_plane - 1; for ( $i = 7; $i < 10; ++$i ) { if ( $line{$i} == $lower_half_cols ) { $high = floor($low + (($high - $low) / 2)); } else { $low = ceil($high - (($high - $low) / 2)); } } assert($low == $high); $col = $low; // $seat_id = ($row * 8) + $col; $all_seat_ids[] = $seat_id; if ( $seat_id > $highest_seat_id ) { $highest_seat_id = $seat_id; } } fclose($fp); sort($all_seat_ids); for ( $i = 0; $i < count($all_seat_ids); ++$i ) { $curr = $all_seat_ids[$i]; $next = $all_seat_ids[$i + 1]; if ( $curr + 1 != $next ) { print ($curr + 1) . "\n"; break; } }