#C11013. Ride Safety Check
Ride Safety Check
Ride Safety Check
You are given a ride represented as a JSON object. The ride has a name, a max_speed, a duration, and a list of safety_checks. Each safety check is an object with a name and a status (either "passed" or "failed").
A ride is considered safe to operate if all of its safety checks pass or if there are no safety checks. Otherwise, the ride is not safe to operate. In other words, the ride is safe if and only if $$ \forall check \in safety\_checks,\; check.status = 'passed'\quad \text{or}\quad safety\_checks \; \text{is empty.} $$
Your task is to output the safety status in the following format:
<Ride Name> is safe to operate.
or <Ride Name> is not safe to operate.
inputFormat
The input is provided on STDIN as a JSON string representing a ride object with the following keys:
name
: A string denoting the ride's name.max_speed
: An integer representing the maximum speed.duration
: An integer representing the duration (in minutes).safety_checks
: An array of objects. Each object has:name
: A string representing the name of the safety check.status
: A string that is either "passed" or "failed".
outputFormat
Print a single line to STDOUT indicating the safety status of the ride in the following format:
<Ride Name> is safe to operate.
or
<Ride Name> is not safe to operate.## sample
{"name": "Thunderbolt", "max_speed": 120, "duration": 3, "safety_checks": [{"name": "Harness check", "status": "passed"}, {"name": "Brake check", "status": "passed"}, {"name": "Speed control", "status": "passed"}]}
Thunderbolt is safe to operate.