Check Water Bottle Empty
Given the current water level in milliliters and the bottle's total capacity, determine whether the bottle is empty. Return true if the water level is 0, false otherwise.
For example, if the water level is 0 ml, the bottle is empty — return true. If the level is 500 ml, the bottle is not empty — return false. The capacity is provided but is not needed to check emptiness — only the current level matters.
This problem teaches boolean logic and comparison operators. Checking whether a value equals zero is one of the simplest conditional checks. It is used in inventory systems (checking stock depletion), sensor monitoring (detecting empty tanks), and state management (checking if a queue is drained).
The solution compares the water level to 0 and returns the boolean result. If level equals 0, the bottle is empty. Otherwise, it has some water remaining.
Edge cases include a negative water level (should not occur but would technically not be empty), a level equal to exactly 0 (empty), and a level exceeding capacity (the bottle still has water, so not empty).
Example Input & Output
There is still water left in the bottle.
Any amount above zero means the bottle is not empty.
No water left means the bottle is empty.
Algorithm Flow

Solution Approach
Compare the water level to 0 and return whether they are equal as a boolean result.
Return the result of the comparison level == 0. This expression produces true when the water level is exactly 0 and false when there is any water remaining. The capacity parameter is provided for context in real-world scenarios but is not required for the emptiness check — only the current level determines whether the bottle is empty.
This is the simplest possible boolean function: it performs a single comparison and returns the result directly. The equality operator (==) compares two values and produces a boolean outcome without needing any conditional branching in the code.
Time complexity is O(1), space complexity is O(1).
Best Answers
program check_water_bottle_empty
dictionary
amount: integer
algorithm
input(amount)
if amount = 0 then
output("EMPTY")
else
output("HAS WATER")
endif
endprogramComments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
