All challenges

Saturday, 17 October 2026

Past

Three rungs, one idea. Solving rung 1 counts. Climb as far as you can.

Two Temperature Scales

functions + changing scales

Rung 1Daily goal5 points

Celsius into Fahrenheit

Write a function called to_fahrenheit

Multiply the Celsius value by 9, divide by 5 using whole-number division //, then add 32. So 100 becomes 212. Any fraction is thrown away, and negative values follow the same steps.

Examples

InputOutput
100212
032
-40-40
3798

There are extra hidden tests, so make it work in general, not just for these.

Rung 2Bonus7 points

Back the other way

Write a function called to_celsius

Now go the opposite direction: take 32 away, multiply by 5, then divide by 9 with //. So 212 becomes 100. Because fractions get thrown away both times, converting a number one way and back does not always land on the number you started with.

Examples

InputOutput
212100
320
-40-40
9836

There are extra hidden tests, so make it work in general, not just for these.

Rung 3Bonus10 points

The warmest reading

Write a function called warmest

readings is a list of small lists, each holding a number and either "C" or "F" to say which scale it is in. Return the warmest reading, still as its own [number, scale] list. Compare them all in Fahrenheit using the rung 1 steps, and if two readings are equally warm return the one that comes first in the list. An empty list returns None.

Examples

InputOutput
[[100, "C"], [100, "F"]][100, "C"]
[[0, "C"], [100, "F"]][100, "F"]
[]None
[[37, "C"], [98, "F"]][37, "C"]

There are extra hidden tests, so make it work in general, not just for these.

Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.