Your question is Array Summation and Currency Recognition. 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.
WePay's Checkout surfaces can receive payment amounts written with either currency symbols or ISO currency codes. Given an array of valid payment strings, recognize each currency and return the total for every currency.
Amounts use at most two decimal places. Do not use floating-point arithmetic because exact totals are required. Store each total in the currency's smallest represented unit, where 12.50 becomes 1250.
Implement aggregate_currency_payments(payments).
payments, a list of strings. Each string is either a supported symbol followed immediately by an amount, such as "\$12.50", or an ISO code followed by one space and an amount, such as "EUR 7.5".$), EUR (€), GBP (£), and JPY (¥).def aggregate_currency_payments(payments):