Skip to main content
Welcome guest. | Register | Login | Post

mystery code (just for fun)

3 replies [Last post]
tbuitenh's picture
Joined: 2005-12-21

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)],''),
  rev = gray[:]
  gray = [[0] + g for g in gray]
  rev = [[1] + r for r in rev]
  gray = gray + rev

I hope you enjoy thinking about this one, and do post your own mystery code ;-)

libervisco's picture
Joined: 2006-05-04

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. Smiling

a thing's picture
Joined: 2005-12-20

A virus?

tbuitenh's picture
Joined: 2005-12-21

Ha! A virus is not a living organism indeed. But no.

1) Each string without spac