tungwaiyip.info

home

about me

links

Media

Yucatán Photos

St Lucia Photos

Photo Album

Videos

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

 

Greece starts to move Idomeni migrants (24 May 2016)

 

Leaked tape forces Brazil minister out (24 May 2016)

 

McCartney 'was depressed after Beatles' (24 May 2016)

 

Unity call after divisive Austria poll (24 May 2016)

 

EgyptAir flight 'did not swerve' (24 May 2016)

 

Syria blames foreign states for blasts (24 May 2016)

 

Sugar shortage hits Coke in Venezuela (24 May 2016)

 

Volcano eruption covers villages in ash (24 May 2016)

 

Review call over European GM crop ban (24 May 2016)

 

Spotify revenues rise but losses widen (24 May 2016)

more »

 

SF Gate

 

Bay Area News (7 Jan 2012)

 

City Insider (11 Feb 2012)

 

Crime Scene (13 Feb 2012)

 

C.W Newius Column (10 Jan 2012)

 

C.W. Nevius Blog (11 Feb 2012)

 

Education News (10 Jan 2012)

 

KALW (11 Feb 2012)

 

Matier and Ross Blog (11 Feb 2012)

 

Zuckerberg to raze 4 houses surrounding Palo Alto home (23 May 2016)

 

Apple Union Square store opens to large crowds (22 May 2016)

 

Streaming video and TV gifts for grads (21 May 2016)

 

Will ‘Tetris’ filmmakers think outside the blocks? (21 May 2016)

 

Does nothing rhymes with ‘algorithm’? Computers are lousy poets (21 May 2016)

 

Airbnb clarifies rules: No class-action lawsuits (21 May 2016)

more »

 


Site feed Updated: 2016-May-24 00:00