문제 페이지 : http://www.pythonchallenge.com/pc/def/linkedlist.php
#!C:\Python26\python.exe
import httplib, re
def gogo(number):
conn = httplib.HTTPConnection('www.pythonchallenge.com')
conn.request('GET', '/pc/def/linkedlist.php?nothing=' + str(number))
r1 = conn.getresponse()
data = r1.read()
print data
if data.find('Yes. Divide by two and keep going.') == 0:
return int(number) / 2
else:
tmp = re.search('and the next nothing is [0-9]+', data).group()
return re.search('[0-9]+', tmp).group()
x = gogo(12345)
while 1:
x = gogo(x)
conn.close()