Ивайло обнови решението на 11.10.2015 01:08 (преди около 9 години)
+def convert_to_bgn(price, currency)
+ currencies = { :bgn => 1.00, :usd => 1.7408, :eur => 1.9557, :gbp => 2.6415 }
+ factor = currencies[currency]
+ new_price = price * factor
+ ("%g" % ('%.2f' % new_price)).to_f
+end
+
+def compare_prices(price_one, currency_one, price_two, currency_two)
+ price_one_in_bgn = convert_to_bgn(price_one, currency_one)
+ price_two_in_bgn = convert_to_bgn(price_two, currency_two)
+ price_one_in_bgn <=> price_two_in_bgn
+end