Long time ago my schoolmate pose a challenge, write a program those output is itself. I take on the challenge think I'm fairly good in programming and mathematics. But I can never get it right and this problem haunted me for many years.
def rep(template): print template + 'rep(' + '"'*3 + template + '"'*3 + ")" rep("""def rep(template): print template + 'rep(' + '"'*3 + template + '"'*3 + ")" """)
Now that I'm reading Gödel, Escher, Bach I finally beginning to learn the technique. I am really happy to finally successfully written the program that output itself in Python above!
2011.11.17 comments -