Problem
A cinema charges by age: children under 3 are free, ages 3–12 pay 5, ages 13–64 pay 12, and 65 or older pay 7.
Implement ticket_price(age).
Input
age: The visitor's age in years.
Output
Return the ticket price.
Constraints
0 ≤ age ≤ 120
Examples
Input:
age = 10
Expected output:
expected = 5
Input:
long long age = 10;
Expected output:
long long expected = 5;
Input:
long age = 10;
Expected output:
long expected = 5;
Explanation
10 is between 3 and 12, so the price is 5.
Input:
age = 70
Expected output:
expected = 7
Input:
long long age = 70;
Expected output:
long long expected = 7;
Input:
long age = 70;
Expected output:
long expected = 7;
Explanation
70 is 65 or older, so the senior price of 7 applies.
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
The price depends on which age band the visitor falls into.
Hint 2
Check the youngest and oldest special cases before the middle ranges.
Hint 3
Pay attention to the exact endpoints so ages 3, 13, and 65 get the correct prices.
Expected complexity
O(1) time, O(1) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.