Cody

Problem 2415. Temperature Conversion Utility (Strings)

Solution 856030

Submitted on 24 Mar 2016 by Jean-Marie Sainthillier
• Size: 21
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
T_in = {'100 Celsius', '50degF', '90K', strcat('111',char(176),'R')}; T_to = {'R','C','degF','kelvin'}; T_out = [671.67 10 -297.67 61.6666667]; eps = 1e-3; assert(sum(abs(T_convertor_str(T_in,T_to)-T_out)) < eps)

2   Pass
T_in = {'10C','20degC','30 Celsius','40 Centigrade',strcat('50',char(176),'C'),'60K','70 kelvin','80 FAHRENHEIT'}; T_to = {'R','R','Rankine','deg R','R','R',strcat(char(176),'R'),'degR'}; T_out = [509.67 527.67 545.67 563.67 581.67 108 126 539.67]; eps = 1e-3; assert(sum(abs(T_convertor_str(T_in,T_to)-T_out)) < eps)

3   Pass
T_in = {'100 DEGREES RANKINE','100degC','100K','100F','1000R','1000 centigrade','1000 deg F','1000 kelvin'}; T_to = {'C','degC',strcat(char(176),'C'),'Celsius','centigrade','deg C','degrees Celsius','CENTIGRADE'}; T_out = [-217.5944444 100 -173.15 37.7777778 282.4055556 1000 537.7777778 726.85]; eps = 1e-3; assert(sum(abs(T_convertor_str(T_in,T_to)-T_out)) < eps)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!