Your question is Cloud Storage 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.
For a dentsu cloud analytics workload, each object can be stored in one of several tiers. Calculate the monthly cost of every valid tier for each object, then assign the object to its cheapest tier.
Each object's access pattern includes its stored size, number of reads per month, and total gigabytes retrieved. A tier's cost consists of storage, read requests, and retrieval fees. Return the minimum total monthly cost and the selected tier for each object, preserving input order.
Implement optimize_storage_cost(objects, tiers).
objects is a list of dictionaries containing name, size_gb, reads, and retrieved_gb.tiers is a list of dictionaries containing name, storage_per_gb, request_per_1000, and retrieval_per_gb.total_cost, rounded to two decimal places, and assignments, a list of dictionaries containing each object's name and selected tier name.The cost of assigning an object to a tier is:
size_gb * storage_per_gb + reads / 1000 * request_per_1000 + retrieved_gb * retrieval_per_gb.
def optimize_storage_cost(objects, tiers):