Christmas is approaching and Santa Claus is making preparations. One of the most delicate aspects concerns the equipment. The sled is under great pressure, and even the reindeer have to give their all. In one night they go through all climates. To protect them, Santa Claus calculates the temperature of each location. Obviously, the temperature measured by the thermometer is not enough: he uses the perceived temperature.

### The Puzzle: Baby, It’s Cold Outside ❄️

Dev Advent Calendar problem 18 🎅 is quite simple. I have to calculate the perceived temperature knowing the wind speed and the outside temperature. The result can be either in degrees centigrade or in degrees Fahrenheit.

The hardest thing is to find the correct formula. Or, rather, the most common formula. Searching the internet I found this article:

I omit all the calculations and report only the formula:

``````Perceived Temperature = 13.12 + 0.6215T – 11.37 (V^0.16) + 0.3965T (V^0.16)
``````

With:

• T: temperature in degrees Celsius
• V: wind velocity in kilometers per hour

I can convert to JavaScript to get this function:

Using miles and fahrenheit:

``````Perceived Temperature = 35.74 + 0.6215T – 35.75 (V^0.16) + 0.4275T (V^0.16)
``````

With:

• T: temperature in degrees Fahrenheit
• V: wind velocity in miles per hour

Combining these two pieces of code I get:

### Convert numbers from one system to another

The problem is quite simple but some complications can arise with converting from one measurement system to another.

I am not going to write a full discussion. I will just report some conversion functions

Convert Kilometers and Miles

Convert Celsius and Fahrenheit

That’s all for today.

Tags:

Categorie:

Aggiornato: