Мартин обнови решението на 10.10.2016 23:56 (преди над 8 години)
▸ Покажи разликите+CELSIUM_METRIX = {
+ C: 0,
+ F: 32.8,
+ K: 273.15,
+}
+
+FARENHEIT_METRIX = {
+ F: 0,
+ C: -16.22,
+ K: 254.928
+}
+
+KELVIN_METRIX = {
+ K: 0,
+ C: -271.15,
+ F: -456.87
+}
+
+LIQUIDS_MELT_TEMP = {
+ water: 0,
+ ethanol: -114,
+ gold: 1064,
+ silver: 961.8,
+ copper: 1085
+}
+
+LIQUIDS_BOIL_TEMP = {
+ water: 100,
+ ethanol: 78.37,
+ gold: 2700,
+ silver: 2162,
+ copper: 2567
+}
+
+def convert_between_temperature_units(degree, convert_from, convert_to)
+ case convert_from
+ when "C"
+ degree + CELSIUM_METRIX[convert_to.to_sym].to_f
+ when "F"
+ degree + FARENHEIT_METRIX[convert_to.to_sym].to_f
+ else
+ degree + KELVIN_METRIX[convert_to.to_sym].to_f
+ end
+end
+
+def melting_point_of_substance(liquid, unit)
+ convert_between_temperature_units(LIQUIDS_MELT_TEMP[liquid.to_sym], "C", unit)
+end
+
+def boiling_point_of_substance(liquid, unit)
+ convert_between_temperature_units(LIQUIDS_BOIL_TEMP[liquid.to_sym], "C", unit)
+end