### Les Conquérants de l'Inutile

Jun. 21st, 2011 02:13 pm"0x35 = 53"

Now, if you're a normal person, you'll probably go: "Huh?"

If you're a normal person who just happens to know what hexadecimal is, you may go: "Hey, that's true! Amusing."

If you're enough of a nerd, you may have gone: "Well, DUH!"

Now,

*I'm*a software engineer, so of course, my reaction was: "Hey, neat! I wonder how often that phenomenon occurs for, say, numbers up to a million. Quick, to the Python prompt!"

About one minute and half later, I had figured out how to compute that the quick and dirty way in Python. It took about half another minute for my poor computer to crunch the numbers and come up with the rather disappointingly short list:

`0x35 = 53`

0x173 = 371

0x1415 = 5141

0x18499 = 99481

0x173 = 371

0x1415 = 5141

0x18499 = 99481

(Technically, the list also contains numbers 0 to 9, but that's the boring trivial case.)

Funnily enough, the results are the same for numbers up to a billion — it took my computer a bit longer to figure that one out.

The line of Python code used to come up with these results was — gotta love list comprehension:

`["0x%X = %d" % (n,n) for n in range(1000000000) if "%X" % n == ("%d" % n)[::-1]]`

*(EDIT: Of course, it*is

*terribly suboptimal. Every number whose hexadecimal representation contains the symbols*

`A`to`F`is never going to meet the conditions anyway and should be skipped early. Same for number with trailing zeroes. And so on... Look, I did that real quick, all right? :))Sigh. The things I do for fun... I should really be ashamed. And, no, I honestly didn't expect anyone out there to find that interesting either, but... y'know... That was quick, cheap and easy fun! :)