# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1293: Reverse Fahrenheit

From New Scientist #2451, 12th June 2004 [link]

“Multiplying by 9/5 and adding 32,” I explained to my clever nephew George, “is useless in practice. What you need is some memorable equivalents, like 10 °C being 50 Fahrenheit. Here’s one I’ve invented: 16 °C = 61 °F. See, to get from one to the other you just reverse the two digits.”

“Actually 16 °C = 60.8 °F,” I said.

“So 61 is near enough,” I said.

“Near enough is not exactly right.”

“But you cannot do it exactly,” I objected sourly.

“You can’t, because you insist on boring old base 10. But I bet I can, using other bases,” George retorted. Off he went to investigate, and was soon back. “-90 °C = -130 °F,” he said, “and to base 21 this says -46 °C = -64 °F. I have other examples, including two between the freezing and boiling points of water.”

What were the two examples that George found? Give your answers in the form x °C = y °F where x and y are written in base 10 (and x lies between 0 and 100).

Note: I am waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. The current estimate is that the line will be connected at the end of September 2014.

[enigma1293]

### One response to “Enigma 1293: Reverse Fahrenheit”

1. Jim Randell 16 September 2014 at 3:01 pm

This Python program runs in 34ms.

```from enigma import irange, printf

# consider temperatures between 0 and 100 C
for C in irange(0, 100):
# compute temperature in F
(F, r) = divmod(C * 9, 5)
if r > 0: continue
F += 32
# consider bases where C is two digits
for b in irange(2, C):
(c1, c2) = divmod(C, b)
(f1, f2) = divmod(F, b)
# check both temperatures are 2 digits
if not(0 < c1 < b and 0 < f1 < b): continue
# check one is the reverse of the other
if not(c1 == f2 and c2 == f1): continue

printf("C={C} F={F} b={b} c={c1},{c2} f={f1},{f2}")
```

Solution: 40°C = 104°F, 85°C = 185°F.

The first works in base 17: 40 = 2617, 104 = 6217.

The second works in base 26: 85 = 3726, 185 = 7326.

This site uses Akismet to reduce spam. Learn how your comment data is processed.