mystery code (just for fun)
Fri, 2006-03-03 13:55
I wrote this little python script to draw an illustration for a report I'm writing. Can you figure out what it is?
Yes, it's DNA. But what is special here? When and where is DNA ordered that way? Why?
Hint: it's not inside a living organism.
import string
table = {(0,0):'A', (0,1):'C', (1,0):'T', (1,1):'G'}
gray = [[0],[1]]
for length in range(1,5):
print length
for y in range(2**length):
for x in range(2**length):
print string.join([table[gray[x][i],gray[y][i]] for i in range(length)],''),
print
rev = gray[:]
rev.reverse()
gray = [[0] + g for g in gray]
rev = [[1] + r for r in rev]
gray = gray + rev
print
I hope you enjoy thinking about this one, and do post your own mystery code ;-)










I'm afraid I don't know alot about DNA and biology in general, but the output of your code seems to present an increasing complexity as the number increases, but number of what? :-k
Also, it somehow reminds me of binary code...though hexadecimal could be more like it.
A virus?
Ha! A virus is not a living organism indeed. But no.
hints:
1) Each string without spaces represents a group of strands of DNA with that sequence.
2) Each square represents an order of those groups on a flat surface.
3) There is something special about the order inside the squares. Look carefully. What is it?
4) A well-known algorithm for the same special order in one dimension is used to calculate the twodimensional version. Try finding this algorithm in wikipedia. There's enough information in the code to be able to find it.
5) The reason this order is used is to minimize errors in the production process (ok, that's not a hint, it's a fun fact)
6) The first three don't have much practical use. However those bigger than number four won't easily fit in your screen.
So... have you already figured out what these things are?