Created
April 16, 2013 20:04
-
-
Save zarino/5399144 to your computer and use it in GitHub Desktop.
Another love forecasting app from #PyPool
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
#!/usr/bin/env python | |
# By David, Jonathan, David, and Zarino | |
import sys | |
names = sys.argv | |
score = 0.0 | |
p1 = names[1].lower() | |
p2 = names[2].lower() | |
# People with "x" in their name are awesome | |
if "x" in p1 or "x" in p2: | |
score += 1 | |
# Same length means compatibility | |
if len(p1) == len(p2): | |
score += 1 | |
# Number of common chars | |
for c in p1: | |
if c in p2: | |
score += 2 | |
# Vowels are cool | |
vowels = 'aeiou' | |
for c in vowels: | |
if c in p1 and c in p2: | |
score += 1 | |
# No, really, we like vowels | |
def vowelscheck(p): | |
vowelsmissing = 0 | |
for c in vowels: | |
if c not in p: | |
vowelsmissing += 0.2 | |
return vowelsmissing | |
score -= vowelscheck(p1) | |
score -= vowelscheck(p2) | |
# The perfect score | |
maximum = len(p1) + len(p2) | |
# Your score, loser | |
percent = score / maximum * 100 | |
print "%s's compatibility with %s is %.1f%%!" % (names[1],names[2],percent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment