Spam filter weighted cost

Write codeEasy10 minMeta style

Your task

Not all spam-filter mistakes cost the same: quarantining a real customer email (false positive) triggers a support ticket, while letting spam through (false negative) merely annoys. Given equal-length binary lists y_true and y_pred (1 = spam), plus non-negative integer costs fp_cost and fn_cost, return the total cost: (number of positions with true 0, predicted 1) * fp_cost + (number of positions with true 1, predicted 0) * fn_cost. Example: y_true = [1, 0, 0, 1], y_pred = [0, 1, 0, 1], fp_cost = 1, fn_cost = 5 returns 6.

Examples

error_cost(y_true: list[int], y_pred: list[int], fp_cost: int, fn_cost: int) -> int
Example 1
Inputerror_cost([1, 0, 0, 1], [0, 1, 0, 1], 1, 5)
Output6