Skip to content

Instantly share code, notes, and snippets.

@chriszf
Created September 5, 2012 21:02
Show Gist options
  • Save chriszf/3644708 to your computer and use it in GitHub Desktop.
Save chriszf/3644708 to your computer and use it in GitHub Desktop.
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