Task
Make a complete program or a function which calculates sum of all temperatures which, when written in Celsius and Fahrenheit scale, are anagram of each other.
Description
For example, 275
degree Celsius = 527
degree Fahrenheit, and 527
is anagram of 275
. Non-integer temperatures (either in degree Celsius or degree Fahrenheit) and temperatures colder than 0 degree Celsius (like -40C
= -40F
) will not be considered.
Input
Input is a temperature in format ([1-9][0-9]*)(C|F)
(example: 42F
= 42 degree Fahrenheit, 125C
= 125 degree Celsius, ...).
The program should be able to handle temperature less than 1000000C
.
Output
Output is sum of all temperatures less than the temperature given by input, which, when written in Celsius and Fahrenheit scale, are anagram (without leading zeroes) of each other. Output will be two integers separated by a space. The first one will be the sum in degree Celsius, and the second one will be the sum in degree Fahrenheit.
If there's no such temperature, return or output 0 0
.
Example
- Input :
42C
- There's no such temperature
- Output :
0 0
- Input :
300C
- There's one temperature :
275C
=527F
- Output :
275 527
- There's one temperature :
- Input :
10000F
- There're three temperatures :
275C
=527F
,2345C
=4253F
, and4685C
=8465F
- Output :
7305 13245
- There're three temperatures :