Skip to content

Instantly share code, notes, and snippets.

@srbaker
srbaker / fraud_detection_shortest_code.rb
Created June 14, 2025 12:00 — forked from yshapiraGC/fraud_detection_shortest_code.rb
You're developing a system to analyze transactions for potential fraud. You have a list of transactions, each with a variety of attributes like amount, currency, status, and a fraud score. Your goal is to calculate total amounts for different currencies only for transactions flagged non clean. You shall refactor ONLY the analyze_transactions met…
transactions = [
{ id: 1, amount: 100, currency: 'USD', status: 'potential_fraud', fraud_score: 85 },
{ id: 2, amount: 200, currency: 'EUR', status: 'potential_fraud', fraud_score: 90 },
{ id: 3, amount: 150, currency: 'USD', status: 'clean', fraud_score: 10 },
{ id: 4, amount: 300, currency: 'USD', status: 'potential_fraud', fraud_score: 88 },
{ id: 5, amount: 250, currency: 'EUR', status: 'clean', fraud_score: 5 },
{ id: 6, amount: 400, currency: 'GBP', status: 'potential_fraud', fraud_score: 92 },
{ id: 7, amount: 50, currency: 'GBP', status: 'potential_fraud', fraud_score: 80 }
]