-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenge.py
229 lines (162 loc) · 3.52 KB
/
challenge.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def solve00():
ans = 2**38
print ans
def solve01():
string1 = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp.
bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle
qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."""
ans = ""
for char in string1:
if char >= 'a' and char <= 'z':
new = (ord(char) - 97 + 2) % 26 + 97
ans += chr(new)
else:
ans += char
# print ans
string2 = 'map'
ans = ""
for char in string2:
if char >= 'a' and char <= 'z':
new = (ord(char) - 97 + 2) % 26 + 97
ans += chr(new)
print ans
def solve02():
mystring = ''
with open('prob_02', 'r') as myfile:
for line in myfile:
mystring += line
mystring = mystring.translate(None, '{!@#$%^&*()}[]+_\n')
print mystring
def solve03():
import re
mystring = ''
with open('prob_03', 'r') as myfile:
for line in myfile:
newline = re.sub(r'.*[a-z][A-Z]{3}([a-z])[A-Z]{3}[a-z].*', r"\1", line)
if line != newline:
mystring += newline
mystring = mystring.translate(None, '\n')
print mystring
def solve04():
import urllib2
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345'
html = urllib2.urlopen(url)
mystring = html.read()
mystringlist = mystring.split()
'''
for i in range(200):
newurl = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
newurl += mystringlist.pop()
html = urllib2.urlopen(newurl)
mystring = html.read()
print str(i) + ": " + mystring
mystringlist = mystring.split()
# print str(92118 / 2)
'''
'''
mystringlist = ['33110']
for i in range(200):
newurl = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
newurl += mystringlist.pop()
html = urllib2.urlopen(newurl)
mystring = html.read()
print str(i) + ": " + mystring
mystringlist = mystring.split()
'''
print 'peak.html'
def solve05():
pass
def solve06():
pass
def solve07():
pass
def solve08():
pass
def solve09():
pass
def solve10():
pass
def solve11():
pass
def solve12():
pass
def solve13():
pass
def solve14():
pass
def solve15():
pass
def solve16():
pass
def solve17():
pass
def solve18():
pass
def solve19():
pass
def solve20():
pass
print "0---------------------------------"
solve00()
print
print "1---------------------------------"
solve01()
print
print "2---------------------------------"
solve02()
print
print "3---------------------------------"
solve03()
print
print "4---------------------------------"
solve04()
"""
print
print "5---------------------------------"
solve05()
print
print "6---------------------------------"
solve06()
print
print "7---------------------------------"
solve07()
print
print "8---------------------------------"
solve08()
print
print "9---------------------------------"
solve09()
print
print "10--------------------------------"
solve10()
print
print "11--------------------------------"
solve11()
print
print "12--------------------------------"
solve12()
print
print "13--------------------------------"
solve13()
print
print "14--------------------------------"
solve14()
print
print "15--------------------------------"
solve15()
print
print "16--------------------------------"
solve16()
print
print "17--------------------------------"
solve17()
print
print "18--------------------------------"
solve18()
print
print "19--------------------------------"
solve19()
print
print "20--------------------------------"
solve20()
"""