Check Bus Seat Available
Given the total number of seats on a bus and the number of passengers already seated, determine whether there is at least one seat available. Return true if there are empty seats, false if the bus is full or has no seats.
For example, a bus with 50 seats and 30 passengers has 20 seats available — return true. With 50 seats and 50 passengers, the bus is full — return false. A bus with 0 seats returns false.
This problem teaches the concept of capacity checking — comparing current usage against total capacity. This pattern is used in booking systems, inventory management, and resource allocation.
The solution checks if the number of passengers is less than the total seats. If passengers < seats, there is at least one empty seat and the result is true. Otherwise, the bus is full or has no seats and the result is false.
Edge cases include zero seats (return false even with zero passengers), a completely empty bus (return true if seats > 0), and a bus at exactly full capacity (return false).
Example Input & Output
There are still seats left, so the bus is not full yet.
Every seat is already taken.
If nobody has taken a seat yet, seats are still available.
Algorithm Flow

Solution Approach
Compare the number of passengers to the total seat capacity using the less-than operator.
Return the result of passengers < totalSeats. This evaluates to true when the number of seated passengers is strictly less than the total seats available, meaning at least one seat is empty. It returns false when the bus is full (passengers == seats) or has no seats at all.
Time complexity is O(1), space complexity is O(1).
Best Answers
program check_bus_seat_available
dictionary
total, taken: integer
algorithm
input(total, taken)
if taken < total then
output("AVAILABLE")
else
output("FULL")
endif
endprogramComments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
