Query plan cost comparison
Your task
Implement a tiny cost-based optimizer decision for a single-predicate query. Given total_rows, the estimated matching_rows for the predicate, the per-row cost of a full table scan scan_cost, and the per-matching-row cost of an index lookup index_cost, compute both plan costs: full_scan_cost = total_rows * scan_cost, and index_cost_total = matching_rows * index_cost. Return the string 'index' if the index plan is strictly cheaper, otherwise 'scan' (ties favor 'scan', since a sequential scan avoids random I/O). All inputs are non-negative integers.
Examples
choose_plan(total_rows: int, matching_rows: int, scan_cost: int, index_cost: int) -> strExample 1
Input
choose_plan(1000, 5, 1, 3)Output
"index"