← Questions

Merchant fraud risk scores from a day of transactions

0
StripeCodingLast asked Aug 2026

Each merchant starts the day with a fraud risk score. You get the day's transactions (customer, merchant, hour, amount) and, for each transaction, a rule with a minimum amount, a multiplier, an additive weight and a penalty. Compute every merchant's final score by making three passes over the transactions:

  1. Large amounts: when a transaction exceeds its rule's minimum, multiply the merchant's score by the rule's multiplier.
  2. Repeat customers: once a customer has made three transactions with the same merchant, add the additive weights of those three, then of each later one.
  3. Bursts in one hour: once a customer has made three transactions with the same merchant in the same hour, apply the penalties of those three and then of each later one, added during the afternoon hours and subtracted otherwise.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding