Created
July 4, 2018 22:20
-
-
Save elendiastarman/ebd2444c3e2586d1274a13c4a3393bcf to your computer and use it in GitHub Desktop.
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
import sys | |
import re | |
import webbrowser | |
MESSAGE = """ | |
Thanks! :D | |
For my responses to birthday wishes this year, I'm using people's names to pick a random year and then from there, I pick an interesting fact to share. See here for more details: https://www.facebook.com/elendia.starman/posts/2225244637490115 | |
Your year was {}! Link: {} | |
In that year, _. | |
""" | |
if __name__ == '__main__': | |
name = sys.argv[1] | |
print("Name:", name) | |
chars = re.sub('[^a-z]*', '', name.lower()) | |
print("Chars:", chars) | |
prod = 1 | |
for c in chars: | |
prod *= ord(c) - ord('a') + 1 | |
print("Product:", prod) | |
result = prod % 2018 + 1 | |
print("Prod mod 2018 + 1:", result) | |
url = 'https://en.wikipedia.org/wiki/{}'.format(result) | |
print("Message:") | |
print(MESSAGE.format(result, url)) | |
webbrowser.open(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment