Created
September 5, 2012 21:02
-
-
Save chriszf/3644708 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
def match(m, p): | |
"""Matches each player with their optimal mentor pair""" | |
pairs = [] | |
total_score = 0 | |
while m: | |
mentor = m.pop() | |
player = p.pop() | |
score = mentor.score(player) | |
total_score += score | |
pair = Pair(player, mentor, score) | |
pairs.append(pair) | |
for pair in pairs: | |
print "Player %s is paired with Mentor %s for a score of %d." % (pair.player.name, pair.mentor.name, pair.flf) | |
print "Total fun-learning factor: ", total_score | |
return pairs | |
class Mentor(object): | |
def score(self, player): | |
if self.length % 2 == 0: | |
score = player.num_consonants() | |
else: | |
score = player.num_vowels() * 1.5 | |
if self.length == player.length: | |
print "Whoohoo!" | |
score *= 1.5 | |
return score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment