Last active
March 19, 2017 00:11
-
-
Save noveoko/e630e9b1375753bcb9fe22ba62df9449 to your computer and use it in GitHub Desktop.
Someone posted a puzzle on the internet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I wrote a script to extract +1,000 answers to this question. | |
#The results I came up with regarding the frequency of answers is: | |
#Counter({'6': 761, '3': 400, '9': 341, '-3': 100, '7': 100}) | |
from bs4 import BeautifulSoup | |
import re | |
import collections | |
pattern = '([\-]*\d+)' | |
def extract_data_from_report3(filename): | |
soup = BeautifulSoup(open(filename), "html.parser") | |
trs = soup.find_all("span", class_="message-holder") | |
return trs | |
comments = extract_data_from_report3('all_answers.html') | |
numz = [] | |
for comment in comments: | |
comment = comment.contents | |
numz.append(comment) | |
onlyInt = re.findall(pattern, str(numz)) | |
c = collections.Counter(onlyInt) | |
print(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment