-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlinkdedlist.py
More file actions
executable file
·25 lines (21 loc) · 867 Bytes
/
linkdedlist.py
File metadata and controls
executable file
·25 lines (21 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Q: http://www.pythonchallenge.com/pc/def/linkedlist.php
import urllib
import re
def get_challenge(subject):
text_src=urllib.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s' % subject).read()
return text_src
# text=get_challenge('12345')
# and the next_str nothing is 16044
# Yes. Divide by two and keep going.
# text=get_challenge('8022')
# There maybe misleading numbers in the
# text. One example is 82683. Look only for the next_str nothing and the next_str nothing is 63579
text=get_challenge('63579')
next_str=re.compile('and the next_str nothing is ([0-9]+)').match(text).groups()[0]
print next_str
while next_str:
text=get_challenge(next_str)
print text
next_str=re.compile('and the next_str nothing is ([0-9]+)').match(text).groups()[0]
# peak.html
# Level 5: http://www.pythonchallenge.com/pc/def/peak.html