Сияна обнови решението на 17.10.2016 16:33 (преди около 8 години)
+MELTING_POINTS = {'water' => 0, 'ethanol' => -114, 'gold' => 1064, 'silver' => 961.8, 'copper' => 1085, }
+BOILING_POINTS = {'water' => 100, 'ethanol' => 78.37, 'gold' => 2700, 'silver' => 2162, 'copper' => 2567, }
+
+CONVERSIONS = {
+ 'CtoC' => ->(degrees) { degrees },
+ 'CtoF' => ->(degrees) { degrees * 1.8 + 32 },
+ 'CtoK' => ->(degrees) { degrees + 273.15 },
+ 'FtoC' => ->(degrees) { (degrees - 32) / 1.8 },
+ 'FtoF' => ->(degrees) { degrees },
+ 'FtoK' => ->(degrees) { (degrees + 459.67) * 0.6 },
+ 'KtoC' => ->(degrees) { degrees - 273.15 },
+ 'KtoF' => ->(degrees) { degrees * 1.8 },
+ 'KtoK' => ->(degrees) { degrees },
+}
+
+def convert_between_temperature_units(degrees, input_unit, output_unit)
+ CONVERSIONS[input_unit + 'to' + output_unit].call(degrees)
+end
+
+def melting_point_of_substance(substance, unit)
+ CONVERSIONS['C' + 'to' + unit].call(MELTING_POINTS[substance])
+end
+
+def boiling_point_of_substance(substance, unit)
+ CONVERSIONS['C' + 'to' + unit].call(BOILING_POINTS[substance])
+end