tungwaiyip.info

home

about me

links

Blog

< November 2011 >
SuMoTuWeThFrSa
   1 2 3 4 5
6 7 8 9101112
13141516171819
20212223242526
27282930   

past articles »

Click for San Francisco, California Forecast

San Francisco, USA

 

A Program That Output Itself

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

 

 

blog comments powered by Disqus

past articles »

 

BBC News

 

Delhi riots: 23 killed as Hindu and Muslim groups clash (26 Feb 2020)

 

Singer Duffy 'drugged, raped and held captive' (26 Feb 2020)

 

Sydney baboons go on the run before vasectomy (26 Feb 2020)

 

Appeal for more funds to control locusts (26 Feb 2020)

 

Weinstein's lawyer Donna Rotunno: 'The fight is not over' (26 Feb 2020)

 

White Helmets appeal for help from world powers in Syria's Idlib (26 Feb 2020)

 

Hong Kong to give cash gift of ,200 to residents (26 Feb 2020)

 

Mario Cerciello Rega: US students in court over police murder (26 Feb 2020)

 

Virgin Galactic sees demand for space travel surge (26 Feb 2020)

 

Outdoor heaters: Paris campaigners want them banned (26 Feb 2020)

more »

 

SF Gate

 

As the startup boom deflates, tech is humbled (24 Feb 2020)

 

Dow drops more than 1,000 as outbreak threatens the economy (24 Feb 2020)

 

Ship traffic, February 25 (24 Feb 2020)

 

Can AI flag disease outbreaks faster than humans? Not quite (23 Feb 2020)

 

Ship traffic, February 23 (22 Feb 2020)

 

Firms encouraged to shift strategy after startup stage (22 Feb 2020)

more »


Site feed Updated: 2020-Feb-26 03:00