Skip to content

Instantly share code, notes, and snippets.

@zeimusu
Last active December 17, 2015 20:47
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 zeimusu/df842c108c0f2bee2890 to your computer and use it in GitHub Desktop.
Save zeimusu/df842c108c0f2bee2890 to your computer and use it in GitHub Desktop.
Use a numeralogical technique known to teens from the '80s to predict the love percentage from names
#!/usr/bin/env python3
#Use: LoveCalculator.py "Katy Perry" "Justin Bieber"
import sys
import itertools
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = itertools.tee(iterable)
next(b, None)
return zip(a, b)
def sumline(n):
"""Add pairs of digits in a string of digits.
So "22" -> "4"
"67" -> "13"
"123" -> "25"
"456" -> "911"
"""
result=""
for (a,b) in pairwise(n):
result += str(int(a)+int(b))
return result
name1 = sys.argv[1]
name2 = sys.argv[2]
names = name1 + name2
numberstring = ("".join([str(names.lower().count(k)) for k in 'loves']))
print("LOVES")
while len(numberstring)>2:
print(numberstring)
numberstring = sumline(numberstring)
print(name1, "loves", name2, numberstring+'%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment