This file contains hidden or 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
""" | |
Implementation of hash() differs in Python 2 and Python 3 | |
To use Python 2's hash() in Python 3, use the following snippet. | |
Note that this snippet computes the expected hash only of input of type str | |
Source: https://www.laurentluce.com/posts/python-dictionary-implementation/ | |
""" | |
import numpy as np | |
def str_hash(string): | |
x = np.array([ord(string[0]) << 7], dtype=int) |
This file contains hidden or 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
""" | |
Copy the conversation and provide it to stdin. | |
This program will calculate the number of messages and total length of all messages | |
By each person in the conversation | |
""" | |
from sys import stdin | |
import re | |
raw_conversation = stdin.readlines() | |
message_timestamp = re.compile(r'\[.*8\]') # example: [17:06, 8/7/2018] |