-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel_29.py
More file actions
33 lines (23 loc) · 820 Bytes
/
level_29.py
File metadata and controls
33 lines (23 loc) · 820 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
30
31
32
33
#!/bin/env python
# coding=utf-8
# http://repeat:switch@www.pythonchallenge.com/pc/ring/guido.html
# Count spaces.
import bz2
import re
import requests
PREFIX = "http://repeat:switch@www.pythonchallenge.com/pc/ring/"
url = PREFIX + 'guido.html'
def catch(text, pattern=r'<!--(.*?)-->', cnt=0):
return re.findall(pattern, text, re.DOTALL)[cnt]
def solve(something):
spaces = catch(something,r'</html>\n(.*)').split('\n')
counts = bytes(map(len, spaces))
answer = bz2.decompress(bytes(counts)).decode()
return answer
if __name__ == "__main__":
r = requests.get(url)
something = r.text
answer = solve(something)
print(answer)
# Isn't it clear? I am yankeedoodle!
# http://repeat:switch@www.pythonchallenge.com/pc/ring/yankeedoodle.html