# Sunday Times Teaser 3155 – Increasing temperature

*by Victor Bryant*

#### Published Sunday March 12 2023 (link)

I have written down an above-freezing temperature, a whole number of degrees Celsius, in which the digits are all different and are in decreasing order. I have then calculated the Fahrenheit equivalent. It is also a whole number whose digits are all different, but here the digits are in increasing order.

If I told you the first digit of the Celsius temperature, then you would not be able to calculate the temperature. However, bearing that in mind, if I now told you the final digit of the Celsius temperature, then it would be possible to calculate it.

You should now be able to work out the Celsius and Fahrenheit temperatures.

What are they?

5 Comments
Leave one →

Here is a simple solution:

and here is a slower version that checks all possible solutions:

Using a dictionary instead of matrices gives even tighter code:

Checking all possible solutions:

Using a dictionary without the benefit of ‘defaultdict()’ to store possible solutions. Inspired by Brian’s code for Teaser 3156. Can anyone see a way of compressing lines 18 & 22 into a single assignment statement?