Your question is Currency Conversion Queries. 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.
An Axon cloud platform service receives currency exchange rates and must answer multiple conversion queries. Each exchange rate defines a directed conversion, and the reverse conversion is also available at the reciprocal rate.
Implement convert_currency(rates, queries) to return the conversion multiplier for each query. Return -1.0 when no conversion path exists.
rates is a list of [sourceCurrency, targetCurrency, rate], where currencies are non-empty strings and rate is a positive number.queries is a list of [sourceCurrency, targetCurrency] pairs.1.0 if that currency appears in the exchange-rate graph. Otherwise, return -1.0.a -> b and b -> c, its conversion multiplier is the product of those rates.def convert_currency(rates, queries):