Fictizia / Master-en-Programacion-con-Python_ed1

FICTIZIA » Máster en Programación con Python — 1ª Edición
https://fictizia.com/formacion/master-programacion-python
GNU Affero General Public License v3.0
44 stars 27 forks source link

Problema de listas anidadas #50

Open delapuente opened 5 years ago

delapuente commented 5 years ago

El enunciado puede encontrarse en: https://www.hackerrank.com/challenges/nested-list/problem

def second_score(entrada):
    score_by_name = dict(entrada)

    minimum = min(score_by_name.values())

    names_and_score_except_min = {k: v for k, v in score_by_name.items() if v > minimum}

    second_minimum = min(names_and_score_except_min.values())

    second_min_score_by_name = {k: v for k, v in score_by_name.items() if v == second_minimum}

    second_minimum_names = sorted(list(second_min_score_by_name.keys()))

    for name in second_minimum_names:
        print(name)

def parse_entrada():
    array_size_line = input().strip()
    array_size = int(array_size_line)
    result = []
    for _ in range(array_size):
        name = input()
        score = float(input())
        result.append([name, score])

    return result

if __name__ == '__main__':
    entrada = parse_entrada()
    second_score(entrada)

@ramoncorominas @eun-plata