Росен обнови решението на 12.10.2015 03:26 (преди около 9 години)
+def convert_to_bgn(price, currency)
+ if currency == :usd
+ (price*1.7408).round(2)
+ elsif currency == :eur
+ (price*1.9557).round(2)
+ elsif currency == :gbp
+ (price*2.6415).round(2)
+ else
+ price
+ end
+end
+
+def compare_prices(price_1, currency_1, price_2, currency_2)
+ if convert_to_bgn(price_1, currency_1) == convert_to_bgn(price_2, currency_2)
+ 0
+ elsif convert_to_bgn(price_1, currency_1) < convert_to_bgn(price_2, currency_2)
+ -1
+ else
+ 1
+ end
+end