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

 

Chicago hospital shooting: Medical staff and policeman among four dead (20 Nov 2018)

 

Airbnb removes Israeli West Bank settlement listings (19 Nov 2018)

 

'Ditch the witch': Julia Gillard shocked by 'vile' abuse while Australian PM (20 Nov 2018)

 

Jim Acosta row: White House restores CNN reporter's pass (19 Nov 2018)

 

'Drunk' Canadian curlers kicked out of tournament final (19 Nov 2018)

 

Transgender women in India: 'This is how we survive' (20 Nov 2018)

 

Huge waves hit Tenerife in Spain's Canary Islands (19 Nov 2018)

 

Sophia Florsch: 'No fear of paralysis' for F3 driver after surgery (19 Nov 2018)

 

UK PM seeks business backing for Brexit plan (19 Nov 2018)

 

Thousands flee as Guatemala's Fuego volcano erupts (19 Nov 2018)

more »

 

SF Gate

 

Ship traffic, November 20 (19 Nov 2018)

 

Why the best shopping holiday for travelers may not be Black Friday (18 Nov 2018)

 

Bay Area stores that will be closed on Thanksgiving (18 Nov 2018)

 

‘No morals’: Advertisers react to Facebook report (18 Nov 2018)

 

Ship traffic, November 19 (18 Nov 2018)

 

Delay, deny and deflect: How Facebook’s leaders fought through crisis (17 Nov 2018)

more »


Site feed Updated: 2018-Nov-19 21:00