-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel1_map.py
More file actions
executable file
·29 lines (28 loc) · 828 Bytes
/
level1_map.py
File metadata and controls
executable file
·29 lines (28 loc) · 828 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
26
27
28
29
#!/usr/bin/python
import urllib2
startLower=ord("a")
startUpper=ord("A")
endLower=ord("z")
endUpper=ord("Z")
def Shiftby2(c):
if c.isalpha():
if startLower <= ord(c) <= endLower:
if ord(c)+2 > endLower:
return chr(startLower+ord(c)+2-endLower-1)
else:
return chr(ord(c)+2)
else:
if ord(c)+2 > endUpper:
return chr(startUpper+ord(c)+2-endUpper-1)
else:
return chr(ord(c)+2)
else:
return c
html = urllib2.urlopen(urllib2.Request("http://www.pythonchallenge.com/pc/def/map.html")).read()
for eachline in html.split("\n"):
if eachline.startswith("g fmnc"):
targetline = eachline
resultline=""
for eachchar in targetline:
resultline += Shiftby2(eachchar)
print resultline