Your question is Cloud Cost Efficiency Function. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Macquarie Group's AWS landing zone receives traffic that changes throughout the day. For each traffic interval, calculate the deployment's cost efficiency, defined as total processed requests divided by total cloud cost.
Each interval specifies the number of requests per hour and its duration in hours. The deployment launches the minimum number of instances required to handle that interval, where each instance supports a fixed number of requests per hour. Cost includes instance-hour charges and a per-request processing charge.
Implement calculate_efficiency(traffic, capacity, instance_hourly_cost, request_cost).
traffic is a list of dictionaries, each containing integer fields requests and hours.capacity is the maximum number of requests one instance can process per hour.instance_hourly_cost and request_cost are non-negative costs in dollars.ceil(requests / capacity). Instances run for the entire interval duration.0.0.def calculate_efficiency(traffic, capacity, instance_hourly_cost, request_cost):