Terence Eden. He has a beard and is smiling.
Theme Switcher:

Code Palindromes

· 150 words


An idle thought on a long weekend. Is it possible to create an executable binary which is a palindrome?

It's trivial to create a palindromic program in, say, Python:

 Python 3print("hello") # )"olleh"(tnirp

Save that as test.py and then run cat test.py | rev | python3 and it'll work. But that's boring!

You could do the same by reversing the bits, rather than the characters:

 01110000 01110010 01101001 01101110 
01110100 00101000 00100010 01101000 
01100101 01101100 01101100 01101111 
00100010 00101001 00100000 00100011 
00000100 10010100 01000100 11110110 
00110110 00110110 10100110 00010110 
01000100 00010100 00101110 01110110 
10010110 01001110 00001110

That requires a bit more bit-bashing to run properly. And, if I'm honest, I think padding stuff with reversed comments is cheating.

Is it possible to make an executable assembly program which can be read forwards and back?


Share this post on…

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.