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

 

UK political storm over seized tanker (21 Jul 2019)

 

Hong Kong protests: Police fire tear gas at demonstrators (21 Jul 2019)

 

Ukraine election: President Zelensky's party triumphs - exit polls (21 Jul 2019)

 

Portugal wildfires: Huge blazes force evacuations (21 Jul 2019)

 

South Africa's Cyril President Ramaphosa hits back in corruption row (21 Jul 2019)

 

Ocasio-Cortez: Trump is 'putting millions of Americans in danger' (21 Jul 2019)

 

Golf: Lowry claims first major with Open win (21 Jul 2019)

 

Comic Con: Marvel reveals Blade, Shang Chi and female Thor (21 Jul 2019)

 

Britain's chancellor to quit if Johnson becomes PM (21 Jul 2019)

 

SOS Méditerranée resumes Mediterranean migrant rescues (21 Jul 2019)

more »

 

SF Gate

 

Google Glass lives on as a device to teach autistic children (21 Jul 2019)

 

The best-sounding true wireless headphones (21 Jul 2019)

 

‘Dumbfake’ videos may be worse than deepfakes? (20 Jul 2019)

 

Despite high hopes, self-driving cars are ‘way in the future’ (20 Jul 2019)

 

Dream of retiring abroad? The reality: Medicare doesn’t travel well (19 Jul 2019)

 

Trump says he may intervene in huge Pentagon cloud contract (19 Jul 2019)

more »


Site feed Updated: 2019-Jul-21 12:00