#K15881. Hotel Room Availability Checker
Hotel Room Availability Checker
Hotel Room Availability Checker
You are given information about hotel rooms and their booked days. Each room is described by a room number and a list of dates on which it is already booked. You are also given a list of all days in a specific range. Your task is to determine the days on which each room is available. If a room is booked for every day in the range, output the string Fully Booked
for that room. If no room data is provided, output an empty result.
The solution should parse the input from standard input and produce the availability information as a JSON object on standard output. The JSON object should use the room numbers as keys and the list of available days (or the string Fully Booked
) as values. All formulas and conditions in the description are formatted in LaTeX. For instance, if a room has no available days, then mathematically, if \(\text{available\_days} = \emptyset\), output "Fully Booked".
Example:
Input: 3 101 2 2023-01-01 2023-01-03 102 5 2023-01-01 2023-01-02 2023-01-03 2023-01-04 2023-01-05 103 0 5 2023-01-01 2023-01-02 2023-01-03 2023-01-04 2023-01-05</p>Output: {"101": ["2023-01-02", "2023-01-04", "2023-01-05"], "102": "Fully Booked", "103": ["2023-01-01", "2023-01-02", "2023-01-03", "2023-01-04", "2023-01-05"]}
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- An integer r representing the number of rooms.
- For each of the r rooms, one line containing: the room number (an integer), an integer k representing the number of booked days for this room, followed by k strings each representing a booked date in the format YYYY-MM-DD. (If k is 0, no dates follow.)
- An integer d representing the total number of days in the range.
- d lines, each containing a date string in the format YYYY-MM-DD.
All inputs are separated by whitespace and newlines.
outputFormat
The output should be a single line written to standard output (stdout). It is a JSON-formatted object where the keys are the room numbers (as strings) and the values are either a JSON array of available date strings or the string Fully Booked
if the room is booked for all the provided days.
Note: If there are no rooms in the input, output an empty JSON object: {}
.
3
101 2 2023-01-01 2023-01-03
102 5 2023-01-01 2023-01-02 2023-01-03 2023-01-04 2023-01-05
103 0
5
2023-01-01
2023-01-02
2023-01-03
2023-01-04
2023-01-05
{"101": ["2023-01-02", "2023-01-04", "2023-01-05"], "102": "Fully Booked", "103": ["2023-01-01", "2023-01-02", "2023-01-03", "2023-01-04", "2023-01-05"]}