-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep4.py
29 lines (20 loc) · 881 Bytes
/
step4.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
import json
import requests
HTTPHeaders = {'content-type': 'application/json'}
tokenDict = {'token': '5185bcac830273a1051d4c260585f734'}
challengeURL = 'http://challenge.code2040.org/api/prefix'
validationURL = 'http://challenge.code2040.org/api/prefix/validate'
prefixDict = json.loads(requests.post(challengeURL, data=json.dumps(tokenDict), headers=HTTPHeaders).text)
prefix = prefixDict['prefix']
prefixLength = len(prefix)
words = []
for i in range(0, len(prefixDict['array'])-1):
if(prefixDict['array'][i][0:prefixLength] != prefix):
words.append(unicode(prefixDict['array'][i]))
# print prefixDict['prefix']
# print prefixDict['array']
# print words
answerDict = {'token': '5185bcac830273a1051d4c260585f734', 'array': words}
# print answerDict
response = requests.post(validationURL, data=json.dumps(answerDict), headers=HTTPHeaders)
print response.text