Code Logo

Check Store Open

Published at19 Apr 2026
Easy 0 views
Like0

This problem comes from a simple daily routine question: is the store open right now or not?

You are given the current hour, the opening hour, and the closing hour. The store is considered open when the current hour is at least the opening time and still earlier than the closing time.

For example, if the current hour is 14, the store opens at 9, and closes at 18, the answer is OPEN. But if the current hour is 20, the answer is CLOSED.

So the task is to compare the current time with the store schedule and print the matching status.

Example Input & Output

Example 1
Input
current_hour = 9, open_hour = 9, close_hour = 18
Output
OPEN
Explanation

The opening hour itself still counts as open.

Example 2
Input
current_hour = 14, open_hour = 9, close_hour = 18
Output
OPEN
Explanation

14 is inside the store's working hours.

Example 3
Input
current_hour = 20, open_hour = 9, close_hour = 18
Output
CLOSED
Explanation

20 is later than the closing time.

Algorithm Flow

Recommendation Algorithm Flow for Check Store Open
Recommendation Algorithm Flow for Check Store Open

Solution Approach

A good way to solve this is to check two conditions together.

First, the current hour must not be earlier than the opening hour. Second, it must still be before the closing hour.

The full condition is:

current_hour >= open_hour AND current_hour < close_hour

If that condition is true, the store is open, so you print OPEN.

If that condition is false, the current time falls outside the working hours, so you print CLOSED.

This is a nice example of combining two comparisons into one simple decision.

Best Answers

Solutions Coming Soon

Verified best solutions for this Challenge are still being analyzed and will be available soon.