def gemelo_genetico(persona): p = personas[persona] person = { i[0]: Counter(i[1]) for i in zip(list(p.genoma.keys()), list(p.genoma.values())) } nombres = (x.nombre for x in personas.values() if x.nombre != p.nombre) per = (zip(list(x.genoma.keys()), list(x.genoma.values())) for x in personas.values() if p.nombre != x.nombre) contador = list({x[0]: Counter(x[1]) for x in j} for j in per) numeros_comun = zip(map(lambda x: sum(gem(x, person)), contador), nombres) gemelo = max(numeros_comun) return [gemelo[1]]
def prom(tag_caracteristica): per = ((i.nombre, i.altura, i.color_ojos, i.color_pelo, i.tono_piel, i.forma_nariz, i.pies, i.vello, i.guata, i.prob_vision) for i in personas.values()) dos = {'AAG': 1, 'CTC': 6} genes = (i[dos[tag_caracteristica]] for i in per) return [sum(genes) / len(personas)]
def grado_2(persona): per = ((i.nombre, i.altura, i.color_ojos, i.color_pelo, i.tono_piel, i.forma_nariz, i.pies, i.vello, i.guata, i.prob_vision) for i in personas.values() if i.nombre != persona.nombre) return list(p[0] for p in filter( lambda x: abs(float(x[1]) - float(persona.altura)) <= 0.5 and x[ 3] == persona.color_pelo and x[4] == persona.tono_piel and abs( float(x[6]) - float(persona.pies)) <= 4 and x[9] == persona. prob_vision, per))
def grado__1(persona): per = ((i.nombre, i.altura, i.color_ojos, i.color_pelo, i.tono_piel, i.forma_nariz, i.pies, i.vello, i.guata, i.prob_vision) for i in personas.values() if i.nombre != persona.nombre) return list(p[0] for p in filter( lambda x: float(x[1]) != float(persona.altura) and x[ 2] != persona.color_ojos and x[3] != persona.color_pelo and x[4] != persona.tono_piel and x[5] != persona.forma_nariz and float(x[ 6]) != float(persona.pies) and x[7] != persona.vello and x[ 8] != persona.guata and x[9] != persona.prob_vision, per))
def grado_n(persona): per = ((i.nombre, i.altura, i.color_ojos, i.color_pelo, i.tono_piel, i.forma_nariz, i.pies, i.vello, i.guata, i.prob_vision) for i in personas.values() if i.nombre != persona.nombre) guatas = { 'Modelo': 1, 'Atleta': 2, 'Mañana empiezo la dieta': 3, 'Guaton Parrillero': 4 } return list(p[0] for p in filter( lambda x: abs(float(x[1]) - float(persona.altura)) <= 0.7 and x[ 4] == persona.tono_piel and abs(float(x[6]) - float(persona.pies)) <= 6 and abs(guatas[x[8]] - guatas[persona.guata]) <= 1, per))
def mmax(tag_caracteristica): uno = {'GTC': 2, 'GGA': 3, 'TCT': 4, 'GTA': 5} dos = {'AAG': 1, 'CTC': 6} per = ((i.nombre, i.altura, i.color_ojos, i.color_pelo, i.tono_piel, i.forma_nariz, i.pies, i.vello, i.guata, i.prob_vision) for i in personas.values()) if tag_caracteristica in list(uno.keys()): l = list(map(lambda x: x[uno[tag_caracteristica]], per)) sett = tuple(set(l)) filters = list( map((lambda y: list(filter(lambda x: x == sett[y], l))), range(len(sett)))) do = {i[1]: i[0] for i in map(lambda x: (len(x), x[0]), filters)} maximo = max(do.values()) return [list(do.keys())[list(do.values()).index(maximo)]] else: return [max(map(lambda x: x[dos[tag_caracteristica]], per))]