Натали обнови решението на 17.10.2016 00:28 (преди около 8 години)
+def convert_between_temperature_units( degrees, unit_in, unit_out)
+ if unit_in == 'C' && unit_out == 'K'
+ return degrees + 273.15
+ elsif unit_in == 'C' && unit_out == 'F'
+ return degrees * 1.8 + 32
+ elsif unit_in == 'C' && unit_out == 'C'
+ return degrees
+ elsif unit_in == 'F' && unit_out == 'C'
+ return (degrees - 32) / 1.8
+ elsif unit_in == 'F' && unit_out == 'K'
+ return (degrees + 459.67) * 5 / 9
+ elsif unit_in == 'F' && unit_out == 'F'
+ return degrees
+ elsif unit_in == 'K' && unit_out == 'C'
+ return degrees - 273.15
+ elsif unit_in == 'K' && unit_out == 'F'
+ return degrees * 9 / 5 - 459.67
+ elsif unit_in == 'K' && unit_out == 'K'
+ return degrees
+ end
+end
+
+def melting_point_of_substance(substances, unit)
+ melting_points = {water: 0, ethanol: -114, gold: 1_064, silver: 961.8, copper: 1_085}
+ convert_between_temperature_units(melting_points.fetch(substances.to_sym), 'C', unit)
+end
+
+def boiling_point_of_substance(substances, unit2)
+ boiling_points = {water: 100, ethanol: 78.37, gold: 2_700, silver: 2_162, copper: 2_567}
+ convert_between_temperature_units(boiling_points.fetch(substances.to_sym), 'C', unit2)
+end
+