Created
February 14, 2013 18:28
-
-
Save saml/4955028 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
# -*- coding: utf-8 -*- | |
import csv | |
from cStringIO import StringIO | |
class School(object): | |
def __init__(self, name): | |
self.name = name | |
def __call__(self, row): | |
for k,v in row.iteritems(): | |
l = getattr(self, k) if hasattr(self, k) else [] | |
l.append(float(v)) | |
setattr(self, k, l) | |
def score(self): | |
total = 0.0 | |
for k,v in self.__dict__.iteritems(): | |
if k != 'name': | |
categories = [x for x in v] | |
categories.sort() | |
total += sum(categories[1:-1]) | |
return total | |
def __str__(self): | |
return '%s (%f)' % (self.name, self.score()) | |
file_content = '''name,boobies,vaginas,makeups,bodyline,virginity,boobiewidth,boobieheight,boobiefirmness | |
Mocidade,,,,,,,, | |
9.9,10,10,9.3,9.9,10,10,10,10 | |
10,10,10,10,9.9,10,10,10,10 | |
10,10,10,9.8,10,9.9,10,10,10 | |
10,9.8,10,9.9,9.9,9.9,10,10,10 | |
9.9,10,10,9.7,10,9.8,10,10,10 | |
Rosas de Ouro,,,,,,,, | |
10,9.9,10,9.7,10,10,10,10,9.8 | |
10,10,10,10,10,10,10,9.7,10 | |
10,10,10,9.9,10,10,10,9.6,10 | |
10,9.5,10,10,10,9.9,10,10,9.9 | |
10,9.9,10,9.8,10,9.8,10,9.9,10 | |
Águia de Ouro,,,,,,,, | |
10,10,10,10,10,10,10,10,10 | |
10,10,10,10,9.9,10,10,10,10 | |
10,10,10,10,10,10,10,9.7,10 | |
10,9.5,10,10,10,9.9,10,10,9.9 | |
10,10,9.9,10,10,9.9,10,10,9.9 | |
Dragões da Real,,,,,,,, | |
10,9.6,10,10,10,10,10,10,10 | |
10,10,9.8,9.9,9.9,10,10,10,9.9 | |
10,10,10,9.9,10,9.7,10,10,10 | |
10,9.5,9.9,9.7,10,10,10,9.9,10 | |
9.9,9.7,9.9,9.7,9.9,10,10,10,10 | |
Império de Casa Verde,,,,,,,, | |
9.9,10,10,10,9.7,10,10,10,10 | |
9.9,10,10,10,9.8,10,10,9.7,10 | |
9.8,10,9.8,10,9.9,10,10,9.9,10 | |
9.7,9.8,9.9,9.9,9.8,9.9,10,9.9,9.7 | |
9.9,10,10,9.9,9.9,9.9,9.9,10,9.9 | |
Acadêmicos do Tucuruvi,,,,,,,, | |
9.8,9.7,10,9.8,9.9,10,9.8,9.9,10 | |
9.9,9.9,10,10,10,9.9,10,10,10 | |
10,9.7,10,10,9.8,9.8,10,10,10 | |
9.9,9.7,10,10,9.9,10,10,9.7,10 | |
10,9.6,10,10,9.8,10,10,10,10 | |
Vai-Vai,,,,,,,, | |
9.8,9.9,10,9.8,10,10,10,10,10 | |
9.8,9.8,10,10,9.8,10,10,9.9,10 | |
9.9,10,10,10,9.9,10,10,9.7,10 | |
9.9,9.7,10,10,10,10,10,10,10 | |
9.8,9.6,10,9.7,9.9,10,10,9.7,10 | |
Nenê de Vila Matilde,,,,,,,, | |
10,10,10,9.7,9.8,10,10,9.9,10 | |
10,10,10,9.9,9.7,9.8,10,10,10 | |
10,9.9,9.9,9.7,9.9,10,10,9.9,9.8 | |
10,9.7,9.8,9.8,9.8,10,10,9.7,10 | |
9.9,9.8,9.9,10,9.9,10,9.9,9.9,9.9 | |
Gaviões da Fiel,,,,,,,, | |
9.9,10,10,9.6,9.9,10,10,10,10 | |
10,10,9.8,10,9.9,10,10,9.9,9.9 | |
9.8,9.8,10,9.9,10,10,10,9.9,10 | |
9.9,9.7,9.9,10,9.8,9.9,10,9.9,9.6 | |
9.9,9.5,9.9,9.9,10,9.9,10,9.8,9.9 | |
X-9,,,,,,,, | |
10,10,10,9.9,10,10,10,10,9.7 | |
10,9.9,10,10,9.8,9.8,10,10,10 | |
10,10,10,9.8,9.9,9.9,10,9.9,9.9 | |
10,9.4,10,9.6,10,9.7,10,10,10 | |
10,9.8,10,9.6,9.8,9.9,10,10,9.8 | |
Acadêmicos do Tatuapé,,,,,,,, | |
9.9,9.7,10,9.5,10,10,9.8,9.7,10 | |
9.9,9.9,10,9.9,9.9,9.9,10,9.5,9.8 | |
9.9,10,10,9.9,10,9.4,10,10,10 | |
10,9.4,10,9.9,9.7,10,9.9,9.8,10 | |
9.9,9.8,9.9,9.7,9.9,10,10,10,10 | |
Tom Maior,,,,,,,, | |
10,9.6,9.9,9.3,10,10,10,10,10 | |
10,9.9,10,9.9,10,10,9.9,10,9.8 | |
10,9.9,10,9.9,10,9.7,10,10,9.8 | |
9.8,9.6,9.9,9.8,10,9.8,10,10,9.7 | |
10,9.7,9.9,9.9,9.9,9.7,10,10,10 | |
Mancha Verde,,,,,,,, | |
9.9,10,10,10,10,10,9.9,9.9,9.9 | |
9.9,9.9,9.9,10,10,9.9,10,9.7,9.9 | |
9.9,10,9.8,10,9.9,9.7,10,9.7,10 | |
9.9,9.7,9.8,10,10,9.8,10,9.9,9.8 | |
10,9.9,9.8,9.8,9.9,9.8,10,10,9.9 | |
Unidos de Vila Maria,,,,,,,, | |
9.9,9.5,10,10,9.8,10,10,9.8,9.8 | |
9.9,10,9.6,9.9,10,10,10,9.9,10 | |
10,10,9.6,10,9.9,10,10,9.7,10 | |
9.9,9.7,9.9,10,10,9.9,10,9.9,9.8 | |
9.9,9.7,10,9.9,10,9.7,10,10,9.8''' | |
f = StringIO(file_content) | |
reader = csv.reader(f) | |
header = reader.next() | |
schools = [] | |
school = None | |
for raw_row in reader: | |
row = dict(zip(header, raw_row)) | |
name = row['name'] | |
try: | |
name = float(name) | |
except: | |
if school is not None: | |
schools.append(school) | |
school = School(name) | |
else: | |
row['clothing'] = name | |
del row['name'] | |
school(row) | |
print(max(schools, key = lambda a: a.score())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment