Skip to content

Instantly share code, notes, and snippets.

@a-detiste
Created February 7, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-detiste/bbc832d215ff0edf8b2b to your computer and use it in GitHub Desktop.
Save a-detiste/bbc832d215ff0edf8b2b to your computer and use it in GitHub Desktop.
Sily love calculator
#!/usr/bin/python3
import sys
import hashlib
if len(sys.argv) != 3:
sys.exit('usage: %s name1 name2' % sys.argv[0])
if sys.argv[2] > sys.argv[1]:
name1 = sys.argv[1]
name2 = sys.argv[2]
else:
name1 = sys.argv[2]
name2 = sys.argv[1]
name1 = name1.upper()
name2 = name2.upper()
print(name1,name2)
lovehex = hashlib.md5()
lovehex.update(bytes(name1 + '\0' + name2, 'utf-8'))
lovehex = lovehex.hexdigest()
print(lovehex)
love256 = int(lovehex[0:2], 16)
print(love256)
lovepct = love256 / 256
print("{:.0%}".format(lovepct))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment